From d64e0955d04a40355e312ca4ee57b2c9a8e248cc Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 20 Oct 2011 17:13:01 -0400 Subject: Use new migration style in HABTM join table Yes, we're on Rails 3.1 now. --- activerecord/lib/active_record/associations.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 0952ea2829..2449df079a 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1424,16 +1424,12 @@ module ActiveRecord # join table with a migration such as this: # # class CreateDevelopersProjectsJoinTable < ActiveRecord::Migration - # def self.up + # def change # create_table :developers_projects, :id => false do |t| # t.integer :developer_id # t.integer :project_id # end # end - # - # def self.down - # drop_table :developers_projects - # end # end # # Adds the following methods for retrieval and query: -- cgit v1.2.3 From f0be2cb19274bb6029f84ca274a72c4d7fbee2d3 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 20 Oct 2011 17:15:28 -0400 Subject: Add some note on adding index to HABTM table --- activerecord/lib/active_record/associations.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 2449df079a..34684ad2f5 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1432,6 +1432,10 @@ module ActiveRecord # end # end # + # It's also a good idea to add indexes to each of those columns to speed up the joins process. + # However, in MySQL it is advised to add a compound index for both of the columns as MySQL only + # uses one index per table during the lookup. + # # Adds the following methods for retrieval and query: # # [collection(force_reload = false)] -- cgit v1.2.3