Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Creating a table with migrations when using has_and_belongs_to_many (See related posts)

You can find the information at http://api.rubyonrails.org under the "create_table" method. The short answer is this though,

create_table :table_name, :id => false do |t|

end


:id is the part you're looking for, it defaults to true, which creates the :id as an autoincrementing primary key, if you use migrations and want to create the join table, you don't want an "id" column, so use :id => false to override the create_table method and tell it you don't want that primary key.

You need to create an account or log in to post comments to this site.


Related Posts