いつも忘れるのでメモ。
mailerオプション
script/gen
1 $ rails -v 2 Rails 2.0.2 3 $ script/generate mailer TestMailer welcome 4 exists app/models / 5 create app/views/ test_maile r 6 exists test/unit/ 7 create test/fixtu res/test_m ailer 8 create app/models /test_mail er.rb 9 create test/unit/ test_maile r_test.rb 10 create app/views/ test_maile r/welcome. erb 11 create test/fixtu res/muji_m ailer/welc ome
添付とbodyにURLを追加する時の注意
- URLをbodyに渡すにはurl_forが使えます。
- attachment
はメソッドなので@はいりません(ココはまりました)。 - ファイルを複数添付の時はattachment
を複数回呼べばOKです。 1 @body = {:sender => "satoko", 2 :message => "welcome", 3 :s21g_url => url_for(:host => "www.s21g.c
om", :controller => "top", :action => "index") 4 } 5 6 attachment :content_ty pe => "image/png", 7 :body => File.read("an-image.p ng"), 8 :filename = "test.png" 9 10 attachment :content_ty pe => "image/png", 11 :body => File.read("an-image2. png"), 12 :filename = "test2.png"
generatorのmailerヘルプ
下記でコマンドでヘルプが表示できます
1 $ script/generate mailer --help
Refs
http://wot
http://rai