简体   繁体   中英

Rails mailer error: wrong number of arguments (1 for 2)

Controller

  def mail_test
    @user = User.all.first
    @course = Course.all.first
    examplemailer.student_reminder(@user, @course).deliver
    redirect_to '/'

  end

Mailer controller

  def student_reminder(user, course)
    @user = user
    @course = course
    @url = 'http://www.google.com'
    mail to: @user.email, subject: "Good Job!"
  end

Here, I need to use <%=@user.name%> and <%= @course.title%>.

However, that code doesn't work, ending in the error

ArgumentError in Rails::MailersController#preview wrong number of arguments (1 for 2)

at

 def student_reminder(user, course)

I think I have proper number of arguments (user and course)

如上所述,错误出在MailerController#preview方法中。

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