は私の団体です:railsのcreated_at列の関連付けのソート方法は?ここ
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
私はお気に入り協会ののcreated_atカラムで、ユーザーのお気に入りの投稿をソートしたいです。ただし、これはPost created_at属性でソートされ、Favorites created_at属性ではソートされません。 Favorites created_at属性でソートするにはどうすればよいですか?
@[email protected]('created_at DESC')
あなたはあなたの質問に言い換えることができますか? – beck03076