Rails ActionMailer预览不起作用

时间:2017-11-15 17:04:15

标签: ruby-on-rails actionmailer railstutorial.org cloud9-ide

我在Rails Tutorial应用程序中设置了一个邮件程序,它运行正常。

在访问c9.io中的默认路径时,电子邮件的预览也正常工作:https://app-name.c9users.io/rails/mailers/user_mailer

以前,这让我可以选择哪个出站电子邮件以及我希望查看预览的格式,html或txt。

现在,我在页面上收到了回复:

unknown action

在日志中,我有一个关于IP地址的404,我不明白:

Started GET "/rails/mailers/user_mailer" for 88.210.160.9 at 2017-11-15 16:43:20 +0000
Cannot render console from 88.210.160.9! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Rails::MailersController#preview as HTML
  Parameters: {"path"=>"user_mailer"}
Completed 404 Not Found in 252ms (ActiveRecord: 0.0ms)

日志意味着我无法访问预览,除非我是本地服务器,尽管此前工作正常。如果我尝试访问特定的邮件程序方法,我会在页面上收到相同的错误:

mailer 2

跟踪类似:

Started GET "/rails/mailers/user_mailer/account_activation" for 88.210.160.9 at 2017-11-15 16:57:41 +0000
Cannot render console from 88.210.160.9! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.255
Processing by Rails::MailersController#preview as HTML
  Parameters: {"path"=>"user_mailer/account_activation"}
Completed 404 Not Found in 1ms (ActiveRecord: 0.0ms)

我有与html& amp相关的观点电子邮件的文本版本和工作邮件 - 这一切都按预期工作,但预览不会显示:

class UserMailer < ApplicationMailer

  def account_activation(user)
    @user = user
    mail to: @user.email, subject: "Account activation"
  end

  def password_reset(user)
    @user = user
    mail to: @user.email, subject: "Password reset"
  end

end

任何想法都会受到赞赏。

1 个答案:

答案 0 :(得分:0)

检查您的邮件文件是否在其名称与.erb或.slim扩展名之间带有.html。我有同样的问题。