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.

[PATCH] Restore changed_attributes method in ActiveModel::Dirty

#4308

It seems that this commit removed the changed_attributes method from ActiveModel::Dirty, which lazily loaded the @changed_attributes ivar.

This then required another commit to ensure that the necessary ivars are initialized. However this still has the major drawback of requiring the including class to call super in its initialize method (depending on the inclusion order). This should not be necessary.

This patch restores the changed_attributes method. It is simpler, it uses a common pattern and removes these specific undocumented requirements on the including code.

Reported by Sam Pohlenz · April 1st, 2010 @ 12:01 PM

State: committed
Milestone: 3.0.2
Assigned to: Yehuda Katz (wycats) Yehuda Katz (wycats)
Importance: Low

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • State changed from new to wontfix

    Calling super is normal, not a drawback. Using an ivar for localized implementation is simple; lazy loading for initialization is unnecessary when initialize is at our disposal.

    April 1st, 2010 @ 03:23 PM

  2. Sam Pohlenz
    Sam Pohlenz

    Adding a one-line method (and removing initialize) is simpler than requiring that the including class always call super within its initialize method. Why push this responsibility to the implementer when it is trivial to take care of it in ActiveModel?

    Furthermore, with these previous commits, ActiveModel::Dirty is now the only part of AM to require that super is called within initialize, not to mention that this requirement is now undocumented.

    April 2nd, 2010 @ 12:52 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • State changed from wontfix to open
    • Milestone cleared.

    Good point and a fine reason to lazy-initialize. Sorry for glossing over that!

    April 2nd, 2010 @ 01:51 AM

  4. Repository
    Repository
    • State changed from open to committed

    (from [3adaef8ae73a3061a9fe4c5e0256d80bc09b1cf4]) Restore changed_attributes method in ActiveModel::Dirty and loosen expectation on including class' initialize method.

    [#4308 state:committed]

    Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
    http://github.com/rails/rails/commit/3adaef8ae73a3061a9fe4c5e0256d8...

    April 2nd, 2010 @ 01:58 AM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone set to 3.0.2
    • Importance changed from to Low

    October 15th, 2010 @ 11:01 PM