Hi,

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

  def upload
    @article = Article.find(params[:id])
    @article.uploads.create(params[:file])
    render :nothing => true
  end

end

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

app/controllers/articles_controller.rb:95:in `upload'

where line 95 is @article.uploads.create(params[:file])

Does anyone have an idea what's wrong?

Thanks

Lukas

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to