If using this gem, error occured when copying ActiveRecord object which contains serialized column.
gem 'rails', '3.2.6'
class Temp < ActiveRecord::Base
serialize :item, Array
$ rails c
Loading development environment (Rails 3.2.6)
1.9.3p194 :001 > r1 = Temp.new
=> #<Temp id: nil, item: , created_at: nil, updated_at: nil>
1.9.3p194 :002 > r2 = r1.dup
(Object doesn't support #inspect)
1.9.3p194 :003 > r2.item
NoMethodError: undefined method `unserialized_value' for :Array
from /Users/**/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/attribute_methods/read.rb:72:in `__temp__'
from /Users/**/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands/console.rb:47:in `start'
from /Users/**/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands/console.rb:8:in `start'
from /Users/**/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Thanks for the report. Will take a look - or if you want to make a patch happy to accept it.
The problem seems to stem from composite_primary_keys/base.rb vs active_record/base.rb (I haven't checked against master yet). The missing line of code causes the attributes to be initialised with unserialization, however without it the attributes are accessed normally and unserialized on demand. The method that is eventually triggering the issue is the method generated for the attribute which is generated in attribute_methods/read.rb. I'm running a quick hack against my project's test suite to see what happens, if that turns out a patch should be trivial.
Can you see if 5.0.9 fixes the issue?
Hi, I tried 5.0.9 and it seems to be working fine. Thanks for the fix.