Ruby on rails Rails ActionMailer预览未在开发中呈现

Ruby on rails Rails ActionMailer预览未在开发中呈现,ruby-on-rails,actionmailer,Ruby On Rails,Actionmailer,我已经设置了帐户激活电子邮件。当我转到预览页面时: 视图为空。该页面正确设置了收件人/发件人地址和主题的格式,但电子邮件没有正文 以下是一些服务器日志: Started GET "/rails/mailers/agent_mailer/account_activation?part=text%2Fhtml" for ::1 at 2015-05-19 17:42:27 -0700 Processing by Rails::MailersController#preview as HTML

我已经设置了帐户激活电子邮件。当我转到预览页面时:

视图为空。该页面正确设置了收件人/发件人地址和主题的格式,但电子邮件没有正文

以下是一些服务器日志:

Started GET "/rails/mailers/agent_mailer/account_activation?part=text%2Fhtml" for ::1 at 2015-05-19 17:42:27 -0700
Processing by Rails::MailersController#preview as HTML
  Parameters: {"part"=>"text/html", "path"=>"agent_mailer/account_activation"}
  Agent Load (0.5ms)  SELECT  "agents".* FROM "agents"  ORDER BY "agents"."id" ASC LIMIT 1
  Rendered agent_mailer/account_activation.html.erb within layouts/mailer (0.1ms)
  Rendered agent_mailer/account_activation.text.erb within layouts/mailer (0.0ms)
  Rendered agent_mailer/account_activation.html.erb within layouts/mailer (0.1ms)
  Rendered agent_mailer/account_activation.html.erb within layouts/mailer (0.0ms)

AgentMailer#account_activation: processed outbound mail in 43.5ms
  Rendered text template (0.0ms)
Completed 200 OK in 49ms (Views: 1.8ms | ActiveRecord: 0.5ms) 
我不明白为什么它会将account_activation.html.erb渲染3次。 我已经把头撞在墙上6个小时了,所以任何帮助都将不胜感激:)

这是相关文件

app/mailers/application_mailer.rb:

class ApplicationMailer < ActionMailer::Base
  default from: "admin@example.com"
  layout 'mailer'
end
class AgentMailer < ApplicationMailer
  def account_activation(agent)
    @agent = agent
    mail from: "admin@example.com"
    mail to: agent.email
    mail subject: "Agent Account Activation"
  end
end
class ApplicationMailer
app/views/layouts/mailers.html.erb:

<html>
  <body>
   <%= yield %>
  </body>
</html>
<p>Welcome to Example! Click on the link below to activate your agent account: </p>

<%= link_to "Activate", edit_agent_account_activation_url(@agent.activation_token, email: @agent.email) %>

app/views/layouts/mailers.text.erb:

<%= yield %>
Welcome to Example! Click on the link below to activate your agent account:

<%= edit_agent_account_activation_url(@agent.activation_token, email: @agent.email) %>

app/mailers/agent_mailer.rb:

class ApplicationMailer < ActionMailer::Base
  default from: "admin@example.com"
  layout 'mailer'
end
class AgentMailer < ApplicationMailer
  def account_activation(agent)
    @agent = agent
    mail from: "admin@example.com"
    mail to: agent.email
    mail subject: "Agent Account Activation"
  end
end
class-AgentMailer
app/views/agent\u mailer/account\u activation.html.erb:

<html>
  <body>
   <%= yield %>
  </body>
</html>
<p>Welcome to Example! Click on the link below to activate your agent account: </p>

<%= link_to "Activate", edit_agent_account_activation_url(@agent.activation_token, email: @agent.email) %>
欢迎使用示例!单击下面的链接以激活您的代理帐户:

app/views/agent\u mailer/account\u activation.text.erb:

<%= yield %>
Welcome to Example! Click on the link below to activate your agent account:

<%= edit_agent_account_activation_url(@agent.activation_token, email: @agent.email) %>
欢迎使用示例!单击下面的链接以激活您的代理帐户:
我已经尝试在layouts/mailers文件中添加一些额外的文本,但这也无法呈现。所以我当时认为布局没有被正确调用。但是,当我在应用程序_mailer.rb中放入
布局“something”
时,我得到了一个缺少布局的错误。我注释掉了
@agent=agent
,在
@agent.activation\u令牌上得到了一个零异常


因此,布局和模板似乎正在处理中,但由于某些原因,它们没有被渲染

你不能多次打电话给“邮件”

app/mailers/agent_mailers.rb:

   class AgentMailer < ApplicationMailer
     def account_activation(agent)
       @agent = agent
       mail from: "admin@example.com", to: agent.email, subject: "Agent Account Activation"
     end
   end
class-AgentMailer