This project is archived and is in readonly mode.

#1414 ✓stale
Ariejan de Vroom

update_attribute from STI model does not work

Reported by Ariejan de Vroom | November 19th, 2008 @ 10:42 AM | in 2.x

When creating a STI solution, I noticed that an update_attribute call in the parent model does not work when called on the child models.

See the following gist for details on how to reproduce the problem:

At this moment, I'm completely in the dark about what's causing this problem.

Comments and changes to this ticket

  • Ariejan de Vroom

    Ariejan de Vroom November 19th, 2008 @ 10:52 AM

    • Tag changed from bug, sti, update_attribute to 2.2, bug, rails-2.2, sti, update_attribute

    More info:

    I'm using the latest Rails 2.2 gem with a MySQL database.

  • Frederick Cheung

    Frederick Cheung December 16th, 2008 @ 01:02 PM

    Just for the record, this is nothing to do with STI.

    This happens if - You load a model - You change the association (build, create, or =) - You then change the foreign key

    As you may have already noticed, if foo belongs_to bar changing :bar_id will not cause the value of to change if the association is already loaded and this is slightly connected. During the save activerecord thinks that the current value of the association is and so overwrites the change you made to the foreign key

  • Pratik

    Pratik March 8th, 2009 @ 05:20 PM

    • State changed from “new” to “stale”

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=""></a>

People watching this ticket