Skip to content

Instantly share code, notes, and snippets.

@MikeSilvis
Created April 27, 2012 18:25
Show Gist options
  • Save MikeSilvis/2511552 to your computer and use it in GitHub Desktop.
Save MikeSilvis/2511552 to your computer and use it in GitHub Desktop.
new_user_mailer
class NewUserEmailer
@queue = :emailer
def self.perform(user_id)
user = User.find(user_id)
mail(:to => user.email, :subject => "Welcome #{user.name}")
end
end
require 'resque/server'
uri = URI.parse(ENV["REDISTOGO_URL"])
REDIS = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Dir["#{Rails.root}/app/jobs/*.rb"].each { |file| require file }
ENV["REDISTOGO_URL"] ||= 'redis://redistogo:[email protected]:9640/'
uri = URI.parse(ENV["REDISTOGO_URL"])
Resque.redis = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection }
#Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
def sign_up_confirmation(user)
Resque.enqueue(NewUserEmailer, user.id)
end
@j3j3
Copy link

j3j3 commented May 16, 2012

What an amazing gist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment