From: Murdoc Date: 2006-09-25T06:35:15+09:00 Subject: Ruby on Rails Relationships Hi all, I'm not sure if this is an appropriate group to ask for assitance with Ruby on Rails, so let me know if it isn't. Anyways, I am having trouble figuring out how to setup what would appear to be a simple has_one/belongs_to relationship. I have my tables as follows: address = {address_id(PK), street_number, street_name, ....} venue = {venue_id(PK), venue_name, address_id} Now, logically, each Venue has one address, but an address may be associated to multiple entities. For example: contact = {contact_id, contact_given, contact_surname, address_id} If I put the following: class Venue < ActiveRecord::Base set_table_name "venue" set_primary_key "venue_id" has_one :address end class Address < ActiveRecord::Base set_table_name "address" set_primary_key "address_id" belongs_to :venue end Then rails is expecting the venue_id field to be present in the address table. It seems illogical to setup the relationship with the "belongs_to :address" tag in the Venue model, as a Venue does not belong to an address, it has an address. Is there a way to setup this relationship to use the correct linking? Regards, --