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

Order by association field #93

Open graywh opened 14 years ago

graywh commented 14 years ago

Ordering by a field on an association omits records missing that association because it's not a left join.

class Model < ActiveRecord::Base belongs_to :parent, :class_name => 'Model', :foreign_key => 'parent_id' end

fb = Model.create(:name=>'FooBar') Model.create(:name=>'Foo', :parent=>fb) Model.create(:name=>'Bar', :parent=>fb) Model.count #=> 3 Model.ascend_by_parent_name.count #=> 2

Just a tad bit annoying.