I am very new to Ruby on Rails and have thus far developed web
applications in PHP. I have a problem applying what I have learned
about has_one relations to an existing database. The database looks as
The fields citizenship_jn_id, home_country_jn_id and
travel_country_jn_id are all foreign keys to countries table. I have
tried to model this in the Person class as follows:
class Person < ActiveRecod::Base
has_one :citizenship, :class_name => “Country”, :foreign_key =>
has_one :home_country, :class_name => “Country”, :foreign_key =>
has_one :travel_country_jn_id, :class_name => “Country”, :foreign_key
But this is not correct as the wrong SQL is produced. What would be
correct to have the right associations in the model?
Thanks for helping a newbe!