#111 ✓moved_to_github
Georg Ledermann

Bug: Problems with multiple scopes beginning with the same name

Reported by Georg Ledermann | July 30th, 2009 @ 03:53 PM

Please have a look at this small example:

class Contact < ActiveRecord::Base
  has_many :documents, :as => :object
  has_many :involvements
  has_many :documents_involved, :through => :involvements, :source => :object, :source_type => 'Document'
end

Contact.search(:documents_involved_title_like => 'foo').all

# => NoMethodError: undefined method `involved_title_like' for #<Class:...>

Using Rails 2.3.3 and searchlogic plugin 2.1.13 released 2009-07-29

Comments and changes to this ticket

  • Ben Johnson

    Ben Johnson July 30th, 2009 @ 07:51 PM

    • State changed from “new” to “open”

    I am trying to create a failing test for this in my test suite and can't seem to do it. Do you mind giving that a shot. I am 90% certain this has to do with the order of keywords in the regular expression. Ex:

    /(documents|documents_involved)/

    When it should be

    /(documents_involved|documents)/

    This is a really easy fix, but I want to get a failing test in place first.

  • Georg Ledermann

    Georg Ledermann July 31st, 2009 @ 05:22 AM

    This has got a little bit more complicated because the bug has changed since searchlogic 2.3.3. Now it occurs not every time. I can't reproduce it and can't write a failing test, sorry. But it seems that it has something to do with other calls to Contact.search BEFORE - very strange.

    But I have found a very similar issue, perhaps they are related. Here is a small patch for the specs (just add one line) and the specs will fail:

    diff --git a/vendor/plugins/searchlogic/spec/spec_helper.rb b/vendor/plugins/searchlogic/spec/spec_helper.rb
    index a2b98f0..c155938 100644
    --- a/vendor/plugins/searchlogic/spec/spec_helper.rb
    +++ b/vendor/plugins/searchlogic/spec/spec_helper.rb
    @@ -71,6 +71,7 @@ Spec::Runner.configure do |config|
         class User < ActiveRecord::Base
           belongs_to :company, :counter_cache => true
           has_many :orders, :dependent => :destroy
    +      has_many :orders_big, :class_name => 'Order', :conditions => 'total > 100'
         end
         
         class Order < ActiveRecord::Base
    
  • Ben Johnson

    Ben Johnson August 7th, 2009 @ 06:30 PM

    • State changed from “open” to “moved_to_github”

    [state:"moved_to_github" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket

Pages