Sometimes a lengthy explanation is not quite what we're looking for. So, here's a quick guide to using the relationship indicators in Rails models. (As always, the Rails API should be referenced for the official usage.)
belongs_to
Use belongs_to :something when a table has a one to one relationship. (i.e. a car has one steering wheel.) This relationship always goes on the model that has the foreign key field (i.e. steering_wheel_id)
has_one
Use has_one :something when a table has a one to one relationship. (i.e. a car has one steering wheel.) This relationship goes on the model that does NOT have the foreign key field.
has_many
Use has_many :things when a table has a one to many relationship. (i.e. a car has many tires.)
has_and_belongs_to_many
Use has_and_belongs_to_many :things (habtm for short) when dealing with a many to many relationship. This implies there is a join table with a name consisting of the two related table names, in alphabetical order. (i.e. cars_wheels.) The habtm indicator is needed in both models.
Use habtm when the join table only joins the related tables. If the join table consists of other properties/fields, then a separate model should be used for that table, and the has_many :through approach used.
has_many :through
Use has_many :things, :through => :othertable. (i.e. for the car model - has_many :wheels, :through => :frames) This is the same has_many mentioned above with the addition of the :through indicator.
Use this approach when you have a separate model that contains the join fields. For example the frames table would have car_id, and wheel_id, and also brand_name, and current_wear fields. A separate frame model would be used to access the additional fields. This frame model would use standard has_many entries for cars and wheels.