Ruby on Rails Wednesday, August 31, 2011

Hello,
In the process of updating from 1.9.2-p180 to 1.9.2-p290 I found
that deserialising a serialised attribute as a Hash, which contains
other models, stopped working. If I reference the models which are
included in the hash prior to deseralising everything works fine.

Instantiating the model in p290 without referencing the models
raises:
ActiveRecord::SerializationTypeMismatch: combination was supposed to
be a Hash, but was a String

This is on Rails 3.0.10, the database field holding the attribute
is large enough to hold the serialised attribute. The models in the
hash are Price and a bunch of Shop models.
RVM is used to switch between p180 and p290. The gem versions are
identical (gemset was copied from p180 to p290).


class ListPrice < ActiveRecord::Base
## Referencing the models before deserialising the attribute makes
deserialising work in 1.9.2-p290, but is not needed in 1.9.2-p180
Price
Shop.all.each {|shop| shop}
serialize :combination, Hash

...
end


Any thoughts on what's happening here?

Cheers,
Dan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment