binarylogic / searchlogic

Searchlogic provides object based searching, common named scopes, and other useful tools.
http://rdoc.info/projects/binarylogic/searchlogic
MIT License
1.39k stars 133 forks source link

Searchlogic doesn't sort on associated model's attribute value #90

Open conradwt opened 14 years ago

conradwt commented 14 years ago

I'm not sure if this is a bug or not enough documentation which explains how to perform this type of functionality. Also, how does one properly implement the [ descend | ascend ]by* methods for this type of scenario. For example, I have tried the following:

Membership.belongs_to :user Membership.belongs_to :product # product has a price field associated to it.

Subscription.ascend_by_product_price

Generates the following error message:

Begin Error:

NoMethodError: undefined method ascend_by_price' for #<Class:0x106d73050> from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/conditions.rb:69:inmethod_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_conditions.rb:19:in method_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_ordering.rb:27:inmethod_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/ordering.rb:30:in method_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/or_conditions.rb:24:inmethod_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in method_missing_without_paginate' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/will_paginate-2.3.11/lib/will_paginate/finder.rb:170:inmethod_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_conditions.rb:46:in send' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_conditions.rb:46:inassociation_condition_options' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_ordering.rb:39:in create_association_ordering_condition' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/association_ordering.rb:24:inmethod_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/ordering.rb:30:in method_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/searchlogic-2.3.5/lib/searchlogic/named_scopes/or_conditions.rb:24:inmethod_missing' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/activerecord-2.3.5/lib/active_record/base.rb:1959:in method_missing_without_paginate' from /Users/ctaylor/.rvm/gems/ruby-1.8.7-head/gems/will_paginate-2.3.11/lib/will_paginate/finder.rb:170:inmethod_missing' from (irb):34

End Error: