This project is archived and is in readonly mode.

#5915 ✓stale
Logan Bowers

New "scoped" implementation since v2.3.9 breaks chained scopes with custom methods

Reported by Logan Bowers | November 3rd, 2010 @ 11:34 PM

Using git-bisect, I tracked down an issued to commit bfbdeea, "Use bind instead of instance_exec cause it may be causing memory leaks. Also, provide a simpler and sane implementation for scoped.". This commit changes how scoped works such that it no longer propagates custom methods on scopes.

This is an example of the broken case:

  class MyModel < ActiveRecord::Base
    has_many :widgets do
      def limited_to(x)
        scoped(:conditions => ...)
      end

      def fnord
        "a fnord"
      end
    end
  end

  class Widget < ActiveRecord::Base
  end

  MyModel.find(:first).widgets.limited_to(true).fnord # <- EXPLODES undefined method 'fnord' for #<Class:...>

I'm not sure exactly how the scoping functionality changed with this commit, but it broke this case.

Comments and changes to this ticket

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="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages