Shea Martin
2006-Jun-27 03:37 UTC
[Rails] user.save now workie, but user.update_attributes does
In my User model, I had this: def update_last_login_time self.last_login = Time.now self.save end But last_login was not being set. When I changed it to this it worked: self.update_attribute( :last_login, Time.now ) Any ideas why? ~S
David Felstead
2006-Jun-27 03:45 UTC
[Rails] user.save now workie, but user.update_attributes does
The call to ''save'' will return false if the save fails, usually due to validation problems. Either check the return value of your ''save'' call, or change it to ''save!'' which will raise an exception if the save fails. Cheers, -David Felstead On 6/26/06, Shea Martin <shea08@eastlink.ca> wrote:> In my User model, I had this: > > def update_last_login_time > self.last_login = Time.now > self.save > end > > But last_login was not being set. > When I changed it to this it worked: > > self.update_attribute( :last_login, Time.now ) > > Any ideas why? > > ~S > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >