Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correct deprecation notice in Rails 3

  • Loading branch information...
commit 71fbb4fb94e157d51f1f0418990244341accfa13 1 parent 3cdc059
David Genord II authored bkeepers committed
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/delayed/backend/active_record.rb
View
17 lib/delayed/backend/active_record.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.