ruby 邮件程序 : Wrong number of arguments

标签 ruby mailer postmark

我正在构建我的邮件程序,但我一直遇到:

wrong number of arguments (0 for 1)

说我疯了,但我觉得我定义的一切都是正确的:

Controller (为简洁起见被截断):

def create
@cms484 = Cms484.new(cms484_params)

respond_to do |format|
  if @cms484.save
    SendLink.message(@cms484).deliver_later
    format.html { redirect_to cms484s_path, notice: 'Cms484 was successfully created.' }
    format.json { render :show, status: :created, location: @cms484 }
  else
    format.html { render :new }
    format.json { render json: @cms484.errors, status: :unprocessable_entity }
  end
end

发送链接.rb:

    class SendLink < ApplicationMailer
    def message(cms484)
    @cms484 = cms484
    mail(
      :subject => 'Hello from Postmark',
      :to  => @cms484.recipient ,
      :from => 'info@mysite.com',
      :html_body => '<strong>Hello</strong> user!.',
  end
end

其他人能看到大海捞针吗?还是我完全漏掉了其他东西?

如果重要的话,我会使用 Postmark 进行投递,并根据文档在我的 application.rb 文件中定义这些参数。认为这是一个更简单的事情。

编辑 完整错误:

Completed 500 Internal Server Error in 76ms

ArgumentError (wrong number of arguments (0 for 1)):
  app/mailers/send_link.rb:2:in `message'
  app/mailers/send_link.rb:4:in `message'
  app/controllers/cms484s_controller.rb:38:in `block in create'
  app/controllers/cms484s_controller.rb:36:in `create'

最佳答案

我有一个类似的问题,我将我的 ActionMailer 方法命名为“message”,结果发现它是 Rails 中的保留字并引发了错误。

我假设“mail”是保留字,而“email”不是。

关于 ruby 邮件程序 : Wrong number of arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30610626/

相关文章:

ruby - 无法使用 implode 命令卸载 rvm

ruby - 当通过 OLE 从 Ruby 或 VBS 调用时,Word Document.SaveAs 忽略编码

email - 提升邮件程序错误 : gnu. mail.handler.TextPlain 无法转换为 javax.activation.DataContentHandler

Rails 应用程序 user_mailer 中的 HTML 与文本

node.js - 如何使用 Firebase 云功能发送自定义电子邮件

ruby - 按值的长度对散列进行排序(降序)

c# - AES/GCM (AES-128-GCM) 身份验证标签在 C# 和 Ruby 中不同

PHP代码向用户发送生日祝福

mustache - mustache : if-statement without scoping - is it possible?

mongoid - 如何重写 ActiveJob 以防止序列化错误?