ActiveRecord and sorting on association
问题 I have a simple AR association like this: Question has_many :answers Answer belongs_to :question with `question_id` int(11) NOT NULL, `is_accepted` tinyint(1) DEFAULT NULL, in the answer. I'll have only one is_accpeted answer and am wondering if there is an easy to sort that to the top (just an order by)? thx Edit: here is my Answer class: class Answer < ActiveRecord::Base belongs_to :question end 回答1: the answer is in your schema `is_accepted` tinyint(1) For many databases, ActiveRecord