>
> If you look at the source code for update_attributes, you'll see it
> does a "save" in the method, so once it's finished, the are no changed
> fields (because the record has already been updated).
>
> You need a callback filter to run in your User model; and
> "before_save" seems sensible to me:
>
Or alternatively, as you're looking at the source for ActiveRecord::Base
you'll see that the update_attributes method simply does this:
def update_attributes(attributes)
self.attributes = attributes
save
end
So, instead of messing about with callbacks, you could simply amend your
original code to this (assigning to attributes rather than calling
update_attributes):
@user = User.find(params[:id])
if @user.attributes = params[:user]
send_mail if @user.changed? #But this is always returns false Not
working
@user.save
---------
else
----
end
If your send_mail method relies on the user being saved you might need to
alter it to be:
if @user.changed?
@user.save
send_mail
end
Cheers,
Andy
--
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.