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.

observers should not add an after_find method to the observed class

#625

Observers should not modify observed classes by defining an empty after_find method on the observed class.

First, it's evil to silently add a method.

Second, it slows down instantiating objects of the observed class, because executing the callback chain is expensive. I measure 10-20% difference for my application.

Reported by Stefan Kaes · July 15th, 2008 @ 07:16 PM

State: resolved
Milestone: 2.1.1
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Stefan Kaes
  2. José Valim
    José Valim
    • Tag set to performance

    Very nice!

    +1

    July 16th, 2008 @ 12:06 AM

  3. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 2.1.1
    • State changed from new to open
    • Assigned user set to Jeremy Kemper

    July 16th, 2008 @ 12:48 AM

  4. Repository
    Repository
    • State changed from open to resolved

    (from [6caaa0251610891887cfcfa4e20fe1dfa5fd70c9]) Observers not longer add an after_find method to the observed class.

    [#625 state:resolved]

    http://github.com/rails/rails/co...

    July 16th, 2008 @ 01:03 AM

  5. Repository
    Repository

    (from [fbef982e4b906b879240a35a1ecff447007da6b2]) Observers not longer add an after_find method to the observed class.

    [#625 state:resolved]

    http://github.com/rails/rails/co...

    July 16th, 2008 @ 01:03 AM