This project is archived and is in readonly mode.

#3169 ✓stale
Zack Hobson

Attributes are not serialized in STI subclasses in production mode.

Reported by Zack Hobson | September 8th, 2009 @ 11:54 PM

This was originally reported and patched by Les Hill: https://rails.lighthouseapp.com/projects/8994/tickets/204

The included patch applies to v2.3.4 and fixes this issue for me, but the ticket is stale. I'm regenerating the patch and opening a new ticket in the hopes that this can be fixed in 2.3.x.

This is from his original bug report:

When using STI, if a subclass specifies that an attribute is to be serialized, and that attribute was not specified as serialized in the base class, serialization of the attribute fails.

This bug will only occur in production, not in development mode due to the class reloading in development mode.

class Droid < ActiveRecord::Base end

class R2D2 < Droid serialize :secret_message end

If the R2D2 class is loaded in production after the Droid class is loaded, then the serialization of the secret_message attribute will fail.

Comments and changes to this ticket

  • Mike Aleksiuk

    Mike Aleksiuk February 5th, 2010 @ 03:26 AM

    I don't know if this will help get this fix into trunk faster, or if I'm just wasting comment space, but: I'm having this issue too. Fortunately, my base class doesn't need to use the serialized column that the subclass uses, so my workaround has just been to put 'serialize :secret_message' on the base class, but this has led to confusion and other issues.

  • Rohit Arondekar

    Rohit Arondekar October 9th, 2010 @ 03:14 AM

    • State changed from “new” to “stale”
    • Importance changed from “” to “”

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Pages