Created
September 6, 2008 12:11
-
-
Save masterkain/9136 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Patient < ActiveRecord::Base | |
has_many :documents | |
has_many :reports, :through => :documents do | |
def find_for_parameter(parameter) | |
# report hm parameters | |
find(:all, :joins => :parameters, :conditions => ['parameters.id = ?', parameter.id]) | |
end | |
end | |
# @patient.reports.find_for_parameter(Parameter.first) | |
# SELECT `reports` . * | |
# FROM `reports` | |
# INNER JOIN documents ON ( reports.document_id = documents.id ) parameters | |
# WHERE ( | |
# documents.patient_id =1 | |
# AND ( | |
# parameters.id =14 | |
# ) | |
# ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment