여기 내 협회입니다레일스에서 created_at 열의 연관성을 기준으로 정렬하는 방법은 무엇입니까?
내가 즐겨 찾기 협회의 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
. 그러나이 속성은 Post created_at 속성에 의해 정렬되며 Favorites created_at 속성에는 정렬되지 않습니다. 어떻게 즐겨 찾기 created_at 속성으로 정렬 할 수 있습니까?
@[email protected]('created_at DESC')
당신은 질문을 바꿔 수 있습니까? – beck03076