开发者

How do I trigger an observer when column_name changes?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜