rails チュートリアル11章のメイラーの部分をやっています。applicatoin_mailer.rbのdefault from: の部分を変えてもプレビューで反映されませんでした。
application_mailer.rb
ruby
1class ApplicationMailer < ActionMailer::Base 2 default from: "noreply@example.com" 3 layout 'mailer' 4end 5
user_mailer.rb
ruby
1class UserMailer < ApplicationMailer 2 3 def account_activation(user) 4 @user = user 5 mail to: user.email, subject: "Account activation" 6 end 7 8 def password_reset 9 @greeting = "Hi" 10 11 mail to: "to@example.org" 12 end 13end 14
その後、user_mailer.rbで個別にfrom:で設定したところ、問題なく動作しました。
なぜdefault from: では反映されなかったのでしょうか?
![
application_mailer.rb
ruby
1class ApplicationMailer < ActionMailer::Base 2 layout 'mailer' 3end
user_mailer.rb
ruby
1class UserMailer < ApplicationMailer 2 3 # Subject can be set in your I18n file at config/locales/en.yml 4 # with the following lookup: 5 # 6 # en.user_mailer.account_activation.subject 7 # 8 def account_activation(user) 9 @user = user 10 mail from: "noreply@example.com", 11 to: user.email, 12 subject: 'Account activation' 13 end 14 15 # Subject can be set in your I18n file at config/locales/en.yml 16 # with the following lookup: 17 # 18 # en.user_mailer.password_reset.subject 19 # 20 def password_reset 21 @greeting = "Hi" 22 23 mail to: "to@example.org" 24 end 25end 26
mailer生成
rails generate mailer UserMailer account_activation password_reset
あなたの回答
tips
プレビュー