我是一名初级程序员,我刚刚在我的 Ruby on Rails 4 Web 应用程序中实现了 Mailboxer。一切都很好,但我想让收件人成为用户的名字,而不是他们的电子邮件。我已经搜索了几个小时,但找不到准确的答案。这是我的代码,尽管它几乎完全符合文档的指示。
配置/初始化程序/mailboxer.rb
Mailboxer.setup do |config|
#Configures if you application uses or not email sending for Notifications and Messages
config.uses_emails = true
#Configures the default from for emails sent for Messages and Notifications
config.default_from = "no-reply@mailboxer.com"
#Configures the methods needed by mailboxer
config.email_method = :mailboxer_email
config.name_method = :name
#Configures if you use or not a search engine and which one you are using
#Supported engines: [:solr,:sphinx]
config.search_enabled = false
config.search_engine = :solr
#Configures maximum length of the message subject and body
config.subject_max_length = 255
config.body_max_length = 32000
end
应用程序/模型/user.rb
acts_as_messageable
...
def name
email
end
def mailboxer_email(object)
email
end
任何帮助将不胜感激。我已经尝试过使用代码,但我不能完全得到正确的调整组合。太感谢了!