简体   繁体   中英

Rails 5 mailer preview with Rspec

I can't preview my emails, at http://localhost:3000/rails/mailers/user_mailer

I always get this error: Mailer preview 'user_mailer' not found

spec/previews/user_mailer_preview.rb

class UserMailerPreview < ActionMailer::Preview
  def contact_form
    UserMailer.contact_form("john@example.com", "John", "Hello World!")
  end
end

I tried to add:

config.action_mailer.preview_path = "#{Rails.root}/spec/previews"

but it didn't work.

Any ideas how to solve this problem?

尝试将文件移动到spec/mailers/previews/user_mailer_preview.rb

另一种选择是将environments/development.rb的路径更改为:

config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM