lib/delayed/performable_method.rb in delayed_job-3.0.3 vs lib/delayed/performable_method.rb in delayed_job-3.0.4

- old
+ new

@@ -7,11 +7,11 @@ delegate :method, :to => :object def initialize(object, method_name, args) raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true) - if defined?(ActiveRecord) && object.kind_of?(ActiveRecord::Base) - raise(ArgumentError, 'Jobs cannot be created for records before they\'ve been persisted') if object.attributes[object.class.primary_key].nil? + if object.respond_to?(:new_record?) && object.new_record? + raise(ArgumentError, 'Jobs cannot be created for records before they\'ve been persisted') end self.object = object self.args = args self.method_name = method_name.to_sym