This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NotifierJob | |
| @queue = :urgent | |
| def self.perform(user) | |
| Notifier.welcome(user).deliver | |
| end | |
| end | |
| Qu.enqueue(NotifierJob, User.last) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Queue | |
| @@jobs = [] | |
| def self.enqueue(klass, *arguments) | |
| @@jobs << { :class => klass, :arguments => arguments } | |
| end | |
| def self.work | |
| while job = @@jobs.shift | |
| puts job[:class].perform(*job[:arguments]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Resque.enqueue(NotifierJob, User.first.attributes) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Resque.enqueue(NotifierJob, User.first) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Image < ActiveRecord::Base | |
| after_commit :generate_thumbnail | |
| def generate_thumbnail | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Image < ActiveRecord::Base | |
| after_create :generate_thumbnail | |
| def generate_thumbnail | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :welcome do | |
| task :users do | |
| # Short running process | |
| Users.limit(10).each do |user| | |
| user.welcome | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace :calculate do | |
| task :pi do | |
| # Really long running process | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| */15 * * * * /bin/bash cd /rails/root/ && rake calculate::pi > /dev/null 2>&1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NotifierJob < Struct.new(:user) | |
| def perform | |
| Notifier.welcome(user).deliver | |
| end | |
| end | |
| Delayed::Job.enqueue(NotifierJob.new(User.last)) |