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

ruby-on-rails – 邮箱不发送电子邮件:参数数量错误(1表示0)

发布时间:2020-12-17 02:44:33 所属栏目:百科 来源:网络整理
导读:发送消息时,我可以在我的控制台中看到: Sent mail to You should add method :mail_email in your Messageable model (2093ms)Date: Wed,07 Nov 2012 14:08:50 +0100From: mail@myemail.comto: You should add method :mail_email in your Messageable mode
发送消息时,我可以在我的控制台中看到:

Sent mail to You should add method :mail_email in your Messageable model (2093ms
)
Date: Wed,07 Nov 2012 14:08:50 +0100
From: mail@myemail.com
to: You should add method :mail_email in your Messageable model

以及Mailbox gem的初始化程序:

Mailboxer.setup do |config|

  #Configures if you applications uses or no the email sending for Notifications and Messages
  config.uses_emails = true

  #Configures the default from for the email sent for Messages and Notifications of Mailboxer
  config.default_from = "mail@myemail.com"

  #Configures the methods needed by mailboxer
  config.email_method = :mail_email
  config.name_method = :name

  #Configures if you use or not a search engine and wich one are you using
  #Supported enignes: [:solr,:sphinx] 
  config.search_enabled = false
  config.search_engine = :solr
end

在我的用户模型中,我有:

acts_as_messageable
  def name
    email
  end

 def mail_email
    @mail_email = self.email
 end

但是在发送消息时我看到了这个错误:

ArgumentError in ConversationsController#reply

wrong number of arguments (1 for 0)

Rails.root: C:/rails/sitesale
Application Trace | Framework Trace | Full Trace

app/models/user.rb:17:in `mail_email'
app/controllers/conversations_controller.rb:22:in `reply'

并且控制器方法回复:

def reply
    current_user.reply_to_conversation(conversation,*message_params(:body,:subject))
    redirect_to conversation
  end

解决方法

它应该是:

def mail_email(object)
    email
end

(对象)很重要.

(编辑:李大同)

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

    推荐文章
      热点阅读