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.

Some plugins overriding method_missing crashes

#4372

For example, the plugin searchlogic utilizes method_missing to create new named scopes. When it hits method_missing it creates a named scope (using define_method) to ensure it will never hit method_missing for that named scope again. Sort of a caching mechanism. It works in the same fashion as ActiveRecord’s "find_by_*" methods. This way only the named scopes you need are created and nothing more.

This is awesome, but it implies that in the same application can't be another plugin that overrides method_missing. If two plugins (or custom models) overrides method_missing (even if they use super) only the last override is valid. Moreover most times is necessary to reimplement the respons_to method too.

There will be a mechanism like a chain or something else to prevent this behavior...

ActiveRecord should have a hook in its method_missing implementation, chainable (for use in plugins), that can be defined more than one time; something like on_method_missing do |method_missing_name| ... end declaration to use in models could be nice.

Reported by Mario · April 12th, 2010 @ 05:41 PM

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

Activity

  1. Yehuda Katz (wycats)
    Yehuda Katz (wycats)
    • State changed from new to invalid

    Can't you just call super in the method_missing?

    April 13th, 2010 @ 05:56 AM