加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ruby Mailer:错误的参数数量

发布时间:2020-12-17 02:55:25 所属栏目:百科 来源:网络整理
导读:我正在努力建立我的邮件,但我一直在努力: wrong number of arguments (0 for 1) 叫我疯了,但我觉得我正确定义了一切: 控制器(为简洁而截断): def create@cms484 = Cms484.new(cms484_params)respond_to do |format| if @cms484.save SendLink.message(@cm
我正在努力建立我的邮件,但我一直在努力:

wrong number of arguments (0 for 1)

叫我疯了,但我觉得我正确定义了一切:

控制器(为简洁而截断):

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

SendLink.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方法命名为“消息”,结果发现它是Rails中的保留字并引发了错误.

我认为“邮件”是一个保留字,其中“电子邮件”不是.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读