Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix ActiveRecord::Base#encode_with for Rails 3.0

  • Loading branch information...
commit dcf414be741a67e0db08f437902e4139e7c8d021 1 parent 7d3704b
@albus522 albus522 authored
Showing with 12 additions and 5 deletions.
  1. +12 −5 lib/delayed/psych_ext.rb
View
17 lib/delayed/psych_ext.rb
@@ -1,11 +1,18 @@
if defined?(ActiveRecord)
ActiveRecord::Base.class_eval do
- def encode_with_override(coder)
- encode_with_without_override(coder)
- coder.tag = "!ruby/ActiveRecord:#{self.class.name}"
+ if instance_methods.include?(:encode_with)
+ def encode_with_override(coder)
+ encode_with_without_override(coder)
+ coder.tag = "!ruby/ActiveRecord:#{self.class.name}"
+ end
+ alias_method :encode_with_without_override, :encode_with
+ alias_method :encode_with, :encode_with_override
+ else
+ def encode_with(coder)
+ coder["attributes"] = attributes
+ coder.tag = "!ruby/ActiveRecord:#{self.class.name}"
+ end
end
- alias_method :encode_with_without_override, :encode_with
- alias_method :encode_with, :encode_with_override
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.