Here are my associations:
Class Post belongs_to :user has_many :favorites, :dependent => :destroy has_many :favoriters, :through => :favorites, :source => :user end Class User has_many :posts has_many :favorites, :dependent => :destroy has_many :favorited, :through => :favorites, :source => :post end Class Favorites belongs_to :user, :post end
I want to sort my users favorite posts by the created_at column in the Favorites association. However, this type is created by the Post created_at attribute, not the Favorites created_at attribute. How can I sort the Favorites attribute created_at?
@ posts=@user.favorited.order ('created_at DESC')
source share