Example: an owner has many cats.
In your Cat model, add the line:
belongs_to :owner
in your Owner model, add the line:
has_many :cats
You then need to run a migration on your cats table, to add the foreign key for owners, so Rails can build the associations. From the command line:
rails g migration add_owner_id_to_cats owner_id:integer
This should create a migration file (in the /db folder), with something like the following in it:
class AddFooToPosts < ActiveRecord::Migration
def change
add_column :cats, :owner_id, :integer # ie, table, field name, field type
end
end
then, run your migration.
rake db:migrate
Thanks to the convention over configuration approach, rails will automagically work out that owner_id is a foreign key to the owners table. from there, you'll be able to access cats through owners, and owners through cats:
mog.owner # "Steve"
steve.cats.first # "Mog"
That, of course, is just the tip of the iceberg - you can define all kinds of odd relations, and customise them as much as you want.
JT