I got this error:
NoMethodError in PictureController#new
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.uploaded_file=
and the line code is here:
@picture.uploaded_file = @params[‘picture_file’]
I got this error:
NoMethodError in PictureController#new
You have a nil object when you didn’t expect it!
The error occured while evaluating nil.uploaded_file=
and the line code is here:
@picture.uploaded_file = @params[‘picture_file’]
Can you show a little more code so we can see what’s causing the error?
Are
you using file_column? Where did you initialize @picture, etc.
Fird Abrar wrote:
@picture.uploaded_file = @params[‘picture_file’]
–
View this message in context:
http://www.nabble.com/Upload-File-tf2002132.html#a5498282
Sent from the RubyOnRails Users forum at Nabble.com.
class PictureController < ApplicationController
def new
picture = Picture.new()
@picture.uploaded_file = @params[‘picture_file’]
@picture.save
redirect_to :action => ‘index’
end
end
Steve R. wrote:
Can you show a little more code so we can see what’s causing the error?
Are
you using file_column? Where did you initialize @picture, etc.
Hello,
You forgot the @ sign in the line where you create a new picture object.
Greetings, Joran.
Fird Abrar wrote:
class PictureController < ApplicationController
def new
picture = Picture.new()
@picture.uploaded_file = @params[‘picture_file’]
@picture.save
redirect_to :action => ‘index’
end
endSteve R. wrote:
Can you show a little more code so we can see what’s causing the error?
Are
you using file_column? Where did you initialize @picture, etc.
You left the at-sign off picture when you initialized it. s/b:
@picture = Picture.new
Fird Abrar wrote:
class PictureController < ApplicationController
def new
picture = Picture.new()
@picture.uploaded_file = @params[‘picture_file’]
@picture.save
redirect_to :action => ‘index’
end
end
–
View this message in context:
http://www.nabble.com/Upload-File-tf2002132.html#a5505766
Sent from the RubyOnRails Users forum at Nabble.com.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs