我有一個簡單的範圍問題。我想這樣做的範圍:在RoR中將簡單查詢轉換爲棘手的命名範圍
if article.responses.blank?
return false
elsif article.responses.last.passed.eql?(false)
return true
else
return false
end
所以在文章模型我想有這樣的事情:
scope :failed_response, {
:joins=>[:responses],
:conditions=>["responses.passed = ?", false]
}
的問題是,我只想當所最近響應失敗。我敢肯定,這是一種用花式排序或某種嵌套查詢來做到這一點的方法,但我被卡住了。謝謝!