How do I write this scope to search for attributes on a nested model? (again)
问题 OK, I asked this question earlier today How do I write a scope to search for attributes on a nested model? and got a great answer on searching for attributes in nested models in Rails. In the previous question a scope was written that found all patients that had an admission with a discharge_time of nil (Thanks tjwallace). class Patient < ActiveRecord::Base has_many :admissions scope :admitted, includes(:admissions).where('admissions.discharge_time' => nil) end What I'm trying to do now is to