Tuesday, January 17, 2012

[Rails] How to change the value of User attribute

Dear All
i follow the instruction of Ruby on rails 3 tutorial, now i want to
update the email of the User,
user =User.find(1)
user.update_attributes(:email=>"test@gmail.com")

but the save failed, error message is "password can not be blank",
so i try this one
user.update_attributes(:email=>"test@gmail.com", :password =>"12345678")
then it success,but i dont want to update the password, i try a lots
times that is i want to change the value of other attributes, i must
update the password, if not ,the updating will fail.

how can i update without updating the password ?

--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate