moiristo / deep_cloneable

This gem gives every ActiveRecord::Base object the possibility to do a deep clone that includes user specified associations.
MIT License
785 stars 89 forks source link

Support serialized defaults #55

Closed AskarZinurov closed 8 years ago

AskarZinurov commented 8 years ago

Sometimes it is useful to set default serialized attributes in db level. Rails caches this nicely, but deep clone fails. This is bugfix.

moiristo commented 8 years ago

In essence, you've replaced write_attribute by raw_write_attribute, right? I'll check out your code later so I can test the differences. Unfortunately the Travis build fails now, do you think you can fix that?

AskarZinurov commented 8 years ago

@moiristo yes, seems like default attributes saved in raw format in table definition and cannot be written as is in general. The fails can be rails issue - the modern versions 4.1, 4.2 works fine, The workaround can be just not specifying attribute type for serialization, as I done here

moiristo commented 8 years ago

I tried the code and it works fine for me. As you suggested, I removed the attribute type to keep Travis happy. Thanks for the PR!