Rails:实例变量未在ActionMailer中传出

时间:2016-07-15 08:28:50

标签: ruby-on-rails arguments actionmailer

我有一个邮件BetaInviteMailer,其中包含操作beta_invite,参与nameemail参数如下:

class BetaInviteMailer < ApplicationMailer
  def beta_invite(name, email)
    mail to: email, subject: 'Invitation to my closed bèta'
    @name = name
  end
end

beta_invite.html.erb读取:

Dear <%= @name %>,
... 

在控制台中运行BetaInviteMailer.beta_invite("John Doe", "email@email.com")

变量@name出现了&#39; nil&#39;

我做错了什么?

1 个答案:

答案 0 :(得分:1)

$(".add-btn").click(function() {
    var $li = $(this).toggleClass("hide-me added");
    var $wrap = $li.closest('.label-wrap');
    $wrap.find('h1').toggleClass('top-added', $wrap.find('.added').length > 0)
});

在邮件调用之前定义@variable