Skip to content

Commit

Permalink
Show object when throwing "non-persisted record" error
Browse files Browse the repository at this point in the history
When calling `delay` on a non-persisted record, the error raised now also contains the details about the object.

This make debugging this error easier. And is consistent with the previous error.
  • Loading branch information
dorian committed May 2, 2014
1 parent 62fd8ab commit 59f072d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/delayed/performable_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(object, method_name, args)
raise NoMethodError, "undefined method `#{method_name}' for #{object.inspect}" unless object.respond_to?(method_name, true)

if object.respond_to?(:persisted?) && !object.persisted?
raise(ArgumentError, 'Jobs cannot be created for non-persisted records')
raise(ArgumentError, "job cannot be created for non-persisted record: #{object.inspect}")
end

self.object = object
Expand Down

0 comments on commit 59f072d

Please sign in to comment.