Here’s the thing :
I have a table with languages (name, label, id).
languages
id
name
label
I’d like another table people with primary_language and
secondary_langage
that should refer to a language_id.
people
id
firstname
familyname
primary_language -> language_id
secondary_language -> language_id
Because I got 2 references, I don’t know how I can do. I think I have to
explicitly say in the Person and Language model that primary_language
and secondary_language is a language_id. How can I do ?
In your person model you can say,
belongs_to :primary_language, :class_name => “Language”, :foreign_key
=> “primary_language_id”
for the relation ship.
So in this case People.primary_language will be the language record.
As for the Rails coding use the column name as “primary_language_id”
instead of “primary_language”.
people
id
firstname
familyname
primary_language -> language_id
secondary_language -> language_id
Because I got 2 references, I don’t know how I can do. I think I have to
explicitly say in the Person and Language model that primary_language
and secondary_language is a language_id. How can I do ?
Thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.