I have the task to work with a database that I am not allows to modify. It is a 
legacy database.

In my class I have put some sample data to illustrate what I am trying to do. I 
working with rails 4 and ruby 2.

Can someone please tell me how am I supposed to code this association. There 
are no field_id in any of the tables.

Thank you very much in advance!

class Midatum < ActiveRecord::Base
 # ...,|diagn1 |diagn2 |diagn3
 # ----+-------+-------+------
 #  ...| "0123"| nil   |"0124"
 #  ...| "0123"| nil   |"0124"
 #  ...| "0123"| "1123"| nil

  
 belongs_to :icd9, :foreing_key => :diagn1
 belongs_to :icd9, :foreing_key => :diagn2
 belongs_to :icd9, :foreing_key => :diagn3
end

class icd9 < ActiveRecord::Base
 # icd9  |description 
 # ------+------------
 #"0123" |"some text"
 #"0124" |"some other text"
 #"1123" |"description text"
 #"1133" |"description text"

 has_many :midata, :foreing_key => :icd9, :primary_key => :icd9
end


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/cbfdf8de-55ca-469d-bf3f-9b108167a7fd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to