Converting a simple query into a tricky named scope in RoR
问题 I have a simple scoping question. I would like to do this as a scope: if article.responses.blank? return false elsif article.responses.last.passed.eql?(false) return true else return false end So on the article model I would have something like this: scope :failed_response, { :joins=>[:responses], :conditions=>["responses.passed = ?", false] } The problem is, I only want instances where the most recent response failed. I'm sure these is a way to do this with either fancy sorting or some kind