In Rails 2.2, if you include a belongs_to or references column in a call to the model generator, it will automatically add the belongs_to declaration to the model, as well as creating the foreign key column in the migration. Seems to me that it would be nice if this capability was a bit more consistent.
I've written a path that extends the generator to pass has_many, has_one, and has_and_belongs_to_many "pseudo-attributes" through to the model, creating the appropriate association declarations without adding columns to the migrations or fixtures.
Sample usage:
script/generate model Supplier name:string products:has_many
script/generate model User name:string account:has_one
script/generate model Product name:string parts:has_and_belongs_to_many
#1315 Extend model generator to create association declarations - Ruby on Rails - rails for anyone who wants to have a look.