ActionMailerではまった

久々にActionMailerの使おうと思ったら単純なところでハマった。また忘れそうだからメモっとく。

class ExampleMailer < ActionMailer::Base

  def foo(user, sent_at = Time.now)
    @subject    = "foo"
    @body       = {}
    @recipients = user.mail
    @from       = 'foo@example.com'
    @sent_on    = sent_at
    @headers    = {}
  end

end

↑みたいな感じでクラスを書いた場合、メール送るときは

ExampleMailer.deliver_foo(@user)

ってな感じでメソッド名の前に'deliver_'をつけて呼び出さなきゃいけないのを忘れてた。完全に忘れてた。ActionMailerのドキュメントを見れば一発で分かる。