Moved message delivering into background process.

This commit is contained in:
benni 2012-08-24 14:33:45 +02:00
parent af3875d46b
commit edadb7d8d1
3 changed files with 6 additions and 19 deletions

View file

@ -11,15 +11,6 @@ class ApplicationController < ActionController::Base
def self.current
Thread.current[:application_controller]
end
# Use this method to call a rake task,,
# e.g. to deliver mails after there are created.
def call_rake(task, options = {})
options[:rails_env] ||= Foodsoft.env
args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
system "/usr/bin/rake #{task} #{args.join(' ')} --trace 2>&1 >> #{Rails.root}/log/rake.log &"
end
protected

View file

@ -14,7 +14,7 @@ class MessagesController < ApplicationController
def create
@message = @current_user.send_messages.new(params[:message])
if @message.save
@message.deliver #TODO: Put this into a background job
Message.delay.deliver(@message.id)
redirect_to messages_url, :notice => "Nachricht ist gespeichert und wird versendet."
else
render :action => 'new'