Skip to content

Commit

Permalink
Correct deprecation notice in Rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
David Genord II authored and bkeepers committed Jul 21, 2010
1 parent 3cdc059 commit 71fbb4f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions lib/delayed/backend/active_record.rb
Expand Up @@ -25,11 +25,18 @@ class Job < ::ActiveRecord::Base

before_save :set_default_run_at

named_scope :ready_to_run, lambda {|worker_name, max_run_time|
{:conditions => ['(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name]}
}
named_scope :by_priority, :order => 'priority ASC, run_at ASC'

if ::ActiveRecord::VERSION::MAJOR >= 3
scope :ready_to_run, lambda {|worker_name, max_run_time|
where(['(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name])
}
scope :by_priority, order('priority ASC, run_at ASC')
else
named_scope :ready_to_run, lambda {|worker_name, max_run_time|
{:conditions => ['(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name]}
}
named_scope :by_priority, :order => 'priority ASC, run_at ASC'
end

def self.after_fork
::ActiveRecord::Base.connection.reconnect!
end
Expand Down

0 comments on commit 71fbb4f

Please sign in to comment.