Skip to content

Instantly share code, notes, and snippets.

*/15 * * * * /bin/bash cd /rails/root/ && rake welcome:users > /dev/null 2>&1
class NotifierJob
@queue = :notifications
def self.perform(user)
Notifier.welcome(user).deliver
end
end
Resque.enqueue(NotifierJob, User.last)
class NotifierJob < Struct.new(:user)
def perform
Notifier.welcome(user).deliver
end
end
Delayed::Job.enqueue(NotifierJob.new(User.last))
*/15 * * * * /bin/bash cd /rails/root/ && rake calculate::pi > /dev/null 2>&1
namespace :calculate do
task :pi do
# Really long running process
end
end
namespace :welcome do
task :users do
# Short running process
Users.limit(10).each do |user|
user.welcome
end
end
end
class Image < ActiveRecord::Base
after_create :generate_thumbnail
def generate_thumbnail
end
end
class Image < ActiveRecord::Base
after_commit :generate_thumbnail
def generate_thumbnail
end
end
Resque.enqueue(NotifierJob, User.first)
Resque.enqueue(NotifierJob, User.first.attributes)