I am on Heroku with a custom domain, and I have the Redis add-on. I need help understanding how to create a background worker for email notifications. Users can inbox message each other, and I would like to send a email notification to the user for each new message received. I have the notifications working in development, but I am not good with creating background jobs which is required for Heroku, otherwise the server would timeout.
Messages Controller:
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
User model:
def mailboxer_email(object) if self.no_email email else nil endend
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 = :sphinxend