1
我想根據軌道上ruby欄的最小數據搜索模型。 特別是,我想搜索得分最高的答案數據。 我一直在執行如下,但它並不簡單,因爲它使用數組。 你能告訴不使用數組的方法嗎?基於軌道欄最小數據的搜索模型
#Answer_model
id:Int
name:string
point:Int
#/app/model/answer.rb
class User < ActiveRecord::Base
scope :highest,-> {
order("point ASC")
}
end
#/app/controllers/answer_controllers.rb
@user = Answer.highest[0]