発生している問題
Railsチュートリアル11章の11.2.2 送信メールのプレビュー にてチュートリアル通りに記述し、プレビュー画面にアクセスしたのですが何度やってもメソッド未定義エラーになります。
該当のソースコード
config/environments/development.rb
Rails.application.configure do ・ ・ ・ config.action_mailer.raise_delivery_errors = true config.action_mailer.delivery_method = :test host = '6de6b716239a4dcabaa474528e17a84c.vfs.cloud9.ap-northeast-1.amazonaws.com' # クラウドIDE config.action_mailer.default_url_options = { host: host, protocol: 'https' } ・ ・ ・ end
test/mailers/previews/user_mailer_preview.rb
# Preview all emails at http://localhost:3000/rails/mailers/user_mailer class UserMailerPreview < ActionMailer::Preview # Preview this email at http://localhost:3000/rails/mailers/user_mailer/account_activation def account_activation user = User.first user.activation_token = User.new_token UserMailer.account_activation(user) end # Preview this email at http://localhost:3000/rails/mailers/user_mailer/password_reset def password_reset UserMailer.password_reset end end
試したこと
account_activationメソッドが未定義だと言われているので、コピペし直したり手動で打ち込んだり色々試しましたが改善されませんでした。
どこか別の所に問題があるのでしょうか?
皆様の知恵をお貸し頂ければと思います。
宜しくお願いします。
追記 ~account_activationの呼び出し箇所について~
知識不足によりあっているか分かりませんがおそらくこの部分だと思います。
app/mailers/user_mailer.rb
class UserMailer < ApplicationMailer def account_activation(user) @user = user mail to: user.email, subject: "Account activation" end def password_reset @greeting = "Hi" mail to: "to@example.org" end end
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。