juliamae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-23 21:37 UTC
are serialized fields required?
When I specify that a field is serialized in the model, but create an object of that model without the (optional) serialized field, I run into problems that seem to indicate serialized fields are required. It seems to be taking the nil value of the field and trying to unserialize it, unsuccessfully. So, in my model: class Person < ActiveRecord::Base serialize :research_discipline, Array When I do this: member = Member.new # Member subclasses Person assert !member.valid? I get: ActiveRecord::SerializationTypeMismatch: research_discipline was supposed to be a Array, but was a NilClass So can I have an optional serialized field? Thanks, Julia --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
juliamae-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Jan-24 18:07 UTC
Re: are serialized fields required?
Well I haven''t gotten a reply, but I did find this relevant patch, which was submitted a few days ago: http://dev.rubyonrails.org/ticket/7293 Julia On Jan 23, 4:37 pm, "julia...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <julia...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> When I specify that a field is serialized in the model, but create an > object of that model without the (optional) serialized field, I run > into problems that seem to indicate serialized fields are required. It > seems to be taking the nil value of the field and trying to unserialize > it, unsuccessfully. > > So, in my model: > class Person < ActiveRecord::Base > serialize :research_discipline, Array > > When I do this: > member = Member.new # Member subclasses Person > assert !member.valid? > > I get: > ActiveRecord::SerializationTypeMismatch: research_discipline was > supposed to be a Array, but was a NilClass > > So can I have an optional serialized field? > > Thanks, > Julia--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---