4

When sending a message I can see this in my console:

Sent mail to You should add method :mail_email in your Messageable model (2093ms
)
Date: Wed, 07 Nov 2012 14:08:50 +0100
From: [email protected]
to: You should add method :mail_email in your Messageable model

And the initializers for the 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 = "[email protected]"

  #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

In my user model I have:

acts_as_messageable
  def name
    email
  end

 def mail_email
    @mail_email = self.email
 end

But I get this error in view when sending a message:

 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'

And the controller method reply:

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

1 Answer 1

7

It should be:

def mail_email(object)
    email
end

The (object) is important.

2
  • 4
    interesting, but why ?
    – Keating
    Jul 24, 2013 at 7:31
  • Thanks, this would have taken hours to sort out alone. I wonder why they didn't put a clearer error message in MailDispatcher#call. Jul 7, 2014 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.