4

メッセージを送信すると、コンソールに次のように表示されます。

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

そして、メールボックス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
4

1 に答える 1

7

そのはず:

def mail_email(object)
    email
end

オブジェクト)は重要です。

于 2012-11-07T15:38:58.817 に答える