我正在通过rails教程,并在第10章中设置邮件程序。现在我正在使用account_activation电子邮件。为了确保我以正确的方式进行设置,我甚至根据sample repo对代码进行了两次检查,并且我正在设置它,就像他一样。Rails :: MailersController#预览错误的参数数量(0代表1)
完整的错误是:ArgumentError in Rails::MailersController#preview wrong number of arguments (0 for 1)
,并指向代码在我user_mailer#account_activation
方法
def account_activation(user) #here
@user = user
mail to: user.email, subject: "Account activation"
end
测试代码,这是对检查是这个
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) #setting up the method call here
end
end
我不知道这是为什么因为我通过UserMailer.account_activation(user)
传递了正确数量的参数。我唯一的猜测可能是它可能在看UserMailerPreview#account_activation
(不带参数)的方法,并试图在UserMailer#account_activation
镜像方法,该方法没有参数。
有没有人看到我在做什么错了?任何帮助都将不胜感激。
的帮助表示感谢。我切换并使他们类方法,并仍然没有工作:( –