From 3b9120fa52b76fb8591fe1d0db85d1a940e867d0 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Thu, 16 Dec 2010 20:10:30 -0200 Subject: Generate add_index by default when giving type belongs_to or references --- railties/guides/source/getting_started.textile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'railties/guides/source') diff --git a/railties/guides/source/getting_started.textile b/railties/guides/source/getting_started.textile index 902b7353c0..e371632d87 100644 --- a/railties/guides/source/getting_started.textile +++ b/railties/guides/source/getting_started.textile @@ -811,6 +811,8 @@ class CreateComments < ActiveRecord::Migration t.timestamps end + + add_index :comments, :post_id end def self.down @@ -819,7 +821,7 @@ class CreateComments < ActiveRecord::Migration end -The +t.references+ line sets up a foreign key column for the association between the two models. Go ahead and run the migration: +The +t.references+ line sets up a foreign key column for the association between the two models. And the +add_index+ line sets up an index for this association column. Go ahead and run the migration: $ rake db:migrate -- cgit v1.2.3