I am using Active record against a legacy schema (and I am a rails
newbie). I am having trouble in getting the "belongs_to" and "has_many"
relationships to work.
I have the following 2 tables in the schema:
I have defined the following 2 classes:
class Patient < ActiveRecord::Base
self.primary_key = "PATIENT_ID"
self.table_name = "PATIENT"
has_many :eligibilities, :foreign_key => "PATIENT_ID"
class Eligibility < ActiveRecord::Base
self.primary_key = "ELIGIBILITY_ID"
self.table_name = "ELIGIBILITY_INFORMATION"
Here is my console output:
p = Patient.find('1')
In the DB eligibility_information table has several eligibility records
with PATIENT_ID = '1'. Why is the p.eligibilities collection empty
then? How do i correct this?
It looks like I am missing something basic here. Please help ....