title: Setting options for create_join_table migration in Rails
body: <p>I have some issues. I'm new to RoR</p>
  
  <p>I'm trying to create a join table using Rails migration. Documentation of this is here...
  <a href="http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_join_table" rel="nofollow">http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaStatements.html#method-i-create_join_table</a></p>
  
  <p>When I do... </p>
  
  <pre><code>rails g migration CreateJoinTableUserOffer users offers
  </code></pre>
  
  <p>...it creates the following migration </p>
  
  <pre><code>class CreateJoinTableUserOffer &lt; ActiveRecord::Migration
   def change
     create_join_table:users, :offers  do |t|
           t.index [:user_id, :offer_id]
           t.index [:offer_id, :user_id]
        end       
      end
     end
  </code></pre>
  
  <p>and when I do...</p>
  
  <pre><code>rake db:migrate 
  </code></pre>
  
  <p>it creates...</p>
  
  <pre><code>-- Table: offers_users
  
  -- DROP TABLE offers_users;
  
  CREATE TABLE offers_users
  (
   user_id integer NOT NULL,
   offer_id integer NOT NULL
  )
  WITH (
  
  
  
  OIDS=FALSE
  );
  ALTER TABLE offers_users
   OWNER TO sudeepkaushik;
  
  -- Index: index_offers_users_on_offer_id_and_user_id
  
  -- DROP INDEX index_offers_users_on_offer_id_and_user_id;
  
  CREATE INDEX index_offers_users_on_offer_id_and_user_id
   ON offers_users
   USING btree
   (offer_id, user_id);
  
  -- Index: index_offers_users_on_user_id_and_offer_id
  
  -- DROP INDEX index_offers_users_on_user_id_and_offer_id;
  
  CREATE INDEX index_offers_users_on_user_id_and_offer_id
   ON offers_users
   USING btree
   (user_id, offer_id);
  </code></pre>
  
  <blockquote>
    <p>What I want to do is that I first of all want the table name to be users_offers instead of offers_users, for this you can specify the :table_name in the create_join_table migration. I'm not able to get the syntax of setting this option correctly. Need help here!</p>
    
    <p>2nd, I noticed that this migration doesn't create the foreign keys that I would expect with the Users and Offers tables. Need your comments here also. Do I need to manually create the foreign keys myself?</p>
  </blockquote>