I donโt know why everything is all โNo, you canโtโ, when itโs possible in these areas.
For example, define as part of ActiveRecord :: Base:
named_scope :by_created_at, :order_by => 'created_at'
This allows you to transform a simple relation to an ordered one before it is actually restored:
@items = @items.by_created_at
: , , .
, :
reference =
case (type)
when 1
mycompany
else
myhome
end
@items = reference.items.all(:order_by => 'created_at')