Update array in rails action?
Posted
by Elliot
on Stack Overflow
See other posts from Stack Overflow
or by Elliot
Published on 2009-08-30T18:10:41Z
Indexed on
2010/03/31
9:03 UTC
Read the original article
Hit count: 208
ruby-on-rails
Hey guys,
I have the following code in an action:
@user = @current_user
@user.votes[1430]='up'
@user.update_attributes(params[:user])
Votes is a string type, there is no default value - I just want to set it for the first time when this action occurs.
Unfortunately I get this error: NoMethodError
You have a nil object when you didn't expect it! The error occurred while evaluating nil.votes
any ideas what I'm doing wrong?
© Stack Overflow or respective owner