Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

* Applied bug fix from http://github.com/skanev/searchlogic to make #…

…order work with association ordering.
  • Loading branch information...
commit 64053d5abda003c04826a1fd24dd44208be9b6ec 1 parent 5134843
@binarylogic authored
View
4 CHANGELOG.rdoc
@@ -1,3 +1,7 @@
+== 2.1.13
+
+* Applied bug fix from http://github.com/skanev/searchlogic to make #order work with association ordering.
+
== 2.1.12 released 2009-07-28
* Fixed bug when dealing with scopes that return nil.
View
4 lib/searchlogic/named_scopes/association_ordering.rb
@@ -2,6 +2,10 @@ module Searchlogic
module NamedScopes
# Handles dynamically creating named scopes for associations.
module AssociationOrdering
+ def association_ordering_condition?(name)
+ !association_ordering_condition_details(name).nil?
+ end
+
private
def method_missing(name, *args, &block)
if details = association_ordering_condition_details(name)
View
2  lib/searchlogic/named_scopes/ordering.rb
@@ -24,7 +24,7 @@ def order_condition?(name) # :nodoc:
def method_missing(name, *args, &block)
if name == :order
named_scope name, lambda { |scope_name|
- return {} if !order_condition?(scope_name)
+ return {} if !order_condition?(scope_name) && !association_ordering_condition?(scope_name)
send(scope_name).proxy_options
}
send(name, *args)
View
4 spec/named_scopes/association_ordering_spec.rb
@@ -20,4 +20,8 @@
it "should ascend with a belongs to" do
User.ascend_by_company_name.proxy_options.should == Company.ascend_by_name.proxy_options.merge(:joins => :company)
end
+
+ it "should work through #order" do
+ Company.order('ascend_by_users_username').proxy_options.should == Company.ascend_by_users_username.proxy_options
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.