I want to trigger an email if a new system admin is granted. I have set up开发者_高级运维 a user observer. I want to trigger the email when admin column_name changes to true.
More important this change will happen through the console and not through the UI.
Here is what I have:
def after_update(user)
if user.admin_changed?
AdminMailer.new_system_administrator(user).deliver
end
end
finally using dirty? function to trigger the email
Using the is dirty? function on Db column to trigger the email
精彩评论