I’m pretty much of a rails newbie and ss the title says I’m failing at very basic things.
Anyway. I have 2 models ‘article’ and ‘upload’. Article has_many :uploads Now I’m trying to create an instance of upload in an article in my articles_controller like this:
class ArticlesController < ApplicationController
@article = Article.find(params[:id]) @article.uploads.create(params[:file]) render :nothing => true
If I submit a file to articles/1/upload I get a NoMethodError
You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.delete
where line 95 is @article.uploads.create(params[:file])
Does anyone have an idea what’s wrong?