Rails Devise: after_confirmation

后端 未结 8 1582
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 13:31

Is there a way to create a after_confirmation :do_something ?

The goal is to send an e-mail after the user confirms using Devise :confirmable

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 13:47

    We're combining answers from @Bernát and @RyanJM:

    def confirm!
      super
      if confirmed_at_changed? and confirmed_at_was.nil?
        do_stuff
      end
    end
    

    This seems a bit more performance aware and safe than the two answers separately.

提交回复
热议问题