Skip to content

Commit

Permalink
Fix undefined local variable or method `klass'
Browse files Browse the repository at this point in the history
klass and id were not defined when deserializing ruby objects, causing an undefined error when trying to raise a DeserializationError. This should be fixed now.
  • Loading branch information
neilgupta committed Oct 31, 2014
1 parent 6d0a6b2 commit aa2471a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/delayed/psych_ext.rb
Expand Up @@ -34,8 +34,10 @@ def visit_Psych_Nodes_Mapping(object) # rubocop:disable CyclomaticComplexity, Me
when /^!ruby\/object/
result = super
if defined?(ActiveRecord::Base) && result.is_a?(ActiveRecord::Base)
klass = result.class
id = result[klass.primary_key]
begin
result.class.find(result[result.class.primary_key])
klass.find(id)
rescue ActiveRecord::RecordNotFound => error # rubocop:disable BlockNesting
raise Delayed::DeserializationError, "ActiveRecord::RecordNotFound, class: #{klass}, primary key: #{id} (#{error.message})"
end
Expand Down

0 comments on commit aa2471a

Please sign in to comment.