Hi folks,
I have a simple many-to-many E-R described as below:
Model order.rb:
class Order < ActiveRecord::Base
has_many :cronologies
has_many :statuses, :through => :cronologies
end
Model cronology.rb:
class Cronology < ActiveRecord::Base
belongs_to :order
belongs_to :status
validates_uniqueness_of :order_id, :scope => :status_id
end
Model status.rb:
class Status < ActiveRecord::Base
has_many :cronologies
has_many :orders, :through => :cronologies
end
This code below lets me get all statuses assigned to an order.
@order.statuses
...but how to get statuses ordered by the "created_at" attribute of the cronology table?