Open graywh opened 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.
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.