4
它很簡單,忘記密碼:我怎麼觸發軌發送忘記密碼電子郵件:的Rails 3 /設計如何觸發從模型方法
def send_invitation
raise "Tell devise to send email"
end
多數民衆贊成在我需要從發送電子郵件。這被在少數情況下引發的,但我需要它的工作...
喜歡的東西
def send_invitation
DeviseMailer.forgotten_password.deliver
end
那不是正確的代碼,我甚至不知道去哪裏找
因此,如果我在用戶模型中調用此方法,那麼在after_create回調函數中,此工作將會發揮作用:send_reset_password_instructions(attributes => {:email => self.email}) – 2012-01-12 05:02:02
您可以在模型中將其稱爲self。 send_reset_password_instructions',屬性部分是不必要的,因爲它不是類方法。 – 2012-01-12 05:22:43
非常感謝我挖掘了一點,並弄清楚了:用戶(self)sent_reset_password_instructions – 2012-01-12 05:25:03