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.

Named Scope respond_to? error coercing to array.

#852

test_has_many_associations_have_access_to_named_scopes and test_has_many_through_associations_have_access_to_named_scopes from named_scope_test.rb were erroring as Array#& tried to coerce a Scope to an Array.

Was getting similar to the following:


test_has_many_through_associations_have_access_to_named_scopes(NamedScopeTest):
ArgumentError: wrong number of arguments (2 for 1)
    ./test/cases/../../lib/active_record/associations/association_proxy.rb:176:in `respond_to?'
    ./test/cases/../../lib/active_record/associations/association_proxy.rb:176:in `&'
    ./test/cases/../../lib/active_record/associations/association_proxy.rb:176:in `send'
    ./test/cases/../../lib/active_record/associations/association_proxy.rb:176:in `method_missing'
    ./test/cases/../../lib/active_record/associations/association_collection.rb:285:in `method_missing'
    ./test/cases/named_scope_test.rb:143:in `test_has_many_through_associations_have_access_to_named_scopes'
    ./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:94:in `__send__'
    ./test/cases/../../lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:94:in `run'

Self explanatory patch attached to fix this.

Reported by Tom Lea · August 18th, 2008 @ 05:53 PM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Tom Lea
    Tom Lea

    This could be a Ruby version issue... I'm running...

    
    ruby 1.8.7 (2008-06-20 patchlevel 22) [i686-darwin9]
    

    Seems to be OK on 1.8.5 and 1.9... is anyone else seeing this?

    Contrived none rails example of the behaviour:

    
    class A
      def initialize(a)
        @a = a
      end
    
      def respond_to?(sym)
        super
      end
    
      def to_ary
        @a
      end
    end
    
    [1,2,3] & A.new([1,2,3,4]) # =>
    # ~> -:15:in `respond_to?': wrong number of arguments (2 for 1) (ArgumentError)
    # ~> 	from -:15:in `&'
    # ~> 	from -:15
    

    August 18th, 2008 @ 06:23 PM

  2. Repository
    Repository
    • State changed from new to resolved

    (from [3724dafe71f4afb2ca9f4d7d2526b228aa6c05a3]) Fix incorrect signature for NamedScope#respond_to? [#852 Named Scope respond_to? error coercing to array. state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    August 21st, 2008 @ 04:41 PM

  3. Repository
    Repository

    (from [76886789ac73f25744cd2eced5416918eab1bdc6]) Fix incorrect signature for NamedScope#respond_to? [#852 Named Scope respond_to? error coercing to array. state:resolved]

    Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...

    August 25th, 2008 @ 09:31 AM