Jim Lindley Notes

Sexy Migration Addition

October 19th, 2007

A new foreign key helper for sexy migrations, ‘references’.

create_table :users do |t|
  # old: t.integer :profile_id
  t.references :profile 
end

It can also do polymorphic relations, like so (from the Rails docs)

create_table :taggings do |t| 
   t.references :tag 
   t.references :tagger, :polymorphic => true 
   t.references :taggable, 
                :polymorphic => { :default => 'Photo' } 
end

Changeset #7973

Sorry, comments are closed for this article.