the answer in your circuit
`is_accepted` tinyint(1)
For many databases, ActiveRecord stores the boolean values true and false as 1 and 0
So
question = Question.find(23) questions.answers.order("is_accepted DESC")
should do what you want.
You can also add this as the default order.
class Question has_many :answers, :order => "is_accepted DESC" # rails 3 has_many :answers, -> { order "is_accepted DESC" } # rails 4 end
now question.answers always starts with "is_accepted" first.
source share