【发布时间】:2015-11-25 21:54:07
【问题描述】:
我在 Heroku 上使用自定义域,并且我有 Redis 插件。我需要帮助了解如何为电子邮件通知创建后台工作人员。用户可以互相收件箱消息,我想为收到的每条新消息向用户发送电子邮件通知。我有正在开发中的通知,但我不擅长创建 Heroku 所需的后台作业,否则服务器会超时。
消息控制器:
def create
@recipient = User.find(params[:user])
current_user.send_message(@recipient, params[:body], params[:subject])
flash[:notice] = "Message has been sent!"
if request.xhr?
render :json => {:notice => flash[:notice]}
else
redirect_to :conversations
end
end
用户模型:
def mailboxer_email(object)
if self.no_email
email
else
nil
end
end
Mailboxer.rb:
Mailboxer.setup do |config|
#Configures if you applications uses or no the email sending for Notifications and Messages
config.uses_emails = false
#Configures the default from for the email sent for Messages and Notifications of Mailboxer
config.default_from = "no-reply@domain.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 are you using
#Supported enignes: [:solr,:sphinx]
config.search_enabled = false
config.search_engine = :sphinx
end
【问题讨论】:
标签: ruby-on-rails heroku redis