You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since upgrading to the latest version of paper_trail (from 2.6 to 2.7), our 3.0.20 rails project has been throwing an exception NoMethodError (undefined method dump' for Object:Class)whenever we try to save any model instances that declareserialize :foo` for some field.
After delving into the problem, it appears that paper_trail's new means of serializing serialize attributes on models in version 2.7 seems to be causing my rails 3.0.20 installations to flip out.
The changes here: v2.6.4...v2.7.0#L5R88 specifically the use of ModelName.serialized_attributes['column_name'].dump and ModelName.serialized_attributes['column_name'].load are causing issues with 3.0.20 where ActiveRecord::Coders sadly doesn't exist.
To demonstrate, given a Person model with serialize :name set.
# with rails 3.2.11
irb(main):002:0> Person.serialized_attributes
=> {"name"=>#<ActiveRecord::Coders::YAMLColumn:0x0000000323e788 @object_class=Object>}
Note that above with 3.2.11, the ActiveRecord::Coders::YAMLColumn has both .dump and .load methods available as required.
# with rails 3.0.20
1.8.7-p371 :003 > Person.serialized_attributes
=> {"name"=>Object}
Note that with 3.0.20 the default serialization class Object has no .dump method, and an unrelated .load method. This seems to be because in 3.0.20 the ModelName.serialized_objects hash values contain the class used to validate the output of the unserialized model attribute, however in 3.1.* the serialized_objects hash values instead contain the coder class, as specified by encode_with, defaulting to YAML.
I hope I'm on the right track but I'm surprised no one else has pointed out this incompatibility yet... I'll keep my fingers crossed that there isn't a massive message in your README saying that 2.7 is incompatible with rails 3.0.
The text was updated successfully, but these errors were encountered:
Thanks for the bug report. You are correct about this. Looks like pull #180 is the culprit here. The idea for the pull was absolutely spot on, in the sense that PaperTrail should store serialized versions of objects in the Version table, however, the author must not have realized (I did not either when I approved this pull) that Rails 3.0 does not return a Coder in the serialized_attributes hash.
This isn't a total incompatibility with Rails 3.0.x, but it does cause issues for users who are serializing model attributes.
Impressive response time! I've just tested and the tip of master is working great with our 3.0.20 project (and will switch permanently when you release 2.7.1). Many thanks.
Cheers, thanks for the heads up, otherwise I wouldn't have been aware of it. I'm actually a lot happier with this implementation since it essentially provides a fail-safe.
Since upgrading to the latest version of paper_trail (from
2.6
to2.7
), our3.0.20
rails project has been throwing an exceptionNoMethodError (undefined method
dump' for Object:Class)whenever we try to save any model instances that declare
serialize :foo` for some field.After delving into the problem, it appears that paper_trail's new means of serializing
serialize
attributes on models in version2.7
seems to be causing my rails3.0.20
installations to flip out.The changes here: v2.6.4...v2.7.0#L5R88 specifically the use of
ModelName.serialized_attributes['column_name'].dump
andModelName.serialized_attributes['column_name'].load
are causing issues with 3.0.20 where ActiveRecord::Coders sadly doesn't exist.To demonstrate, given a Person model with
serialize :name
set.Note that above with
3.2.11
, theActiveRecord::Coders::YAMLColumn
has both.dump
and.load
methods available as required.Note that with 3.0.20 the default serialization class
Object
has no.dump
method, and an unrelated.load
method. This seems to be because in3.0.20
theModelName.serialized_objects
hash values contain the class used to validate the output of the unserialized model attribute, however in 3.1.* theserialized_objects
hash values instead contain thecoder
class, as specified by encode_with, defaulting to YAML.I hope I'm on the right track but I'm surprised no one else has pointed out this incompatibility yet... I'll keep my fingers crossed that there isn't a massive message in your README saying that 2.7 is incompatible with rails 3.0.
The text was updated successfully, but these errors were encountered: