You can achieve this by doing like the following:
class Size < ActiveRecord::Base
belongs_to :shoe
scope :brand_ordered, lambda do |way = 'ASC'|
includes(:shoe).order("shoes.brand #{way}")
end
Usage:
@sizes = Size.brand_ordered('DESC')
# or
@sizes = Size.brand_ordered('ASC')
# equivalent:
@sizes = Size.brand_ordered
In the Shoe class:
class Shoe < ActiveRecord::Base
scope :brand_ordered, lambda do |way = 'ASC'|
order("#{self.table_name}.brand #{way}")
end