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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs