Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Attributes are not serialized in STI subclasses in production mode.

#3169

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.

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

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Mike Aleksiuk
    Mike Aleksiuk

    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.

    February 5th, 2010 @ 03:26 AM

  2. Rohit Arondekar
    Rohit Arondekar
    • 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.

    October 9th, 2010 @ 03:14 AM