Conflict with a scope on a column beginning with the name of an association
Reported by etaque (at gmail) | June 16th, 2009 @ 05:38 PM
This is a duplicate of the ticket on github (maybe the wrong
place to post tickeds ?) :
http://github.com/binarylogic/searchlogic/issues#issue/2
Giving those models :
User has_many :classifieds
Classified
User has the column "classifieds_count".
The following search throws an error, because Searchlogic seems
to ignore User.classifieds_count column and try to search on the
associated Classified model :
User.classifieds_count_greater_than(5)
undefined method count_greater_than' for
#<Class:0x3db9234>
Thanks
Emilien
Comments and changes to this ticket
-
Ben Johnson June 20th, 2009 @ 04:58 AM
- → State changed from new to open
Good find, for this I feel like "xxx_count" is obviously a standard, so making a exception for columns like that wouldn't be a huge deal. Also, my regex checks should check the column first anyways. I'll look into this though.
-
Georg Ledermann July 6th, 2009 @ 12:48 PM
Simimilar problem here:
class Debt < ActiveRecord::Base belongs_to :creditor, :class_name => 'Contact', :foreign_key => 'creditor_contact_id' belongs_to :creditor_ledger, :class_name => 'Ledger', :foreign_key => 'creditor_ledger_id' end Debt.search(:creditor_ledger_id => 123) # => NoMethodError: undefined method `ledger_id_equals' for #<Class:0x268a720> -

Joost July 7th, 2009 @ 10:42 AM
Did anyone come up with a quick fix for this bug? I would love to have it! Please let me know!
-

Joost July 13th, 2009 @ 04:53 AM
To fix this change line 83 of named_scopes/associatiions.rb to:
@@@ruby {:order_as => $1, :association => $2, :column => $3} unless column_names.include?("#{$2}_#{$3}")
-
Ben Johnson July 13th, 2009 @ 04:54 PM
- → State changed from open to resolved
This has been fixed. Thanks!
-
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.
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.
