# in db/migrate class CreateArticlesTags < ActiveRecord::Migration def self.up create_table :articles_tags do |t| t.integer :article_id t.integer :tag_id end end def self.down drop_table :articles_tags end end # in app/models/article.rb class Article < ActiveRecord::Base has_and_belongs_to_many :tags end # in app/models/tag.rb class Tag < ActiveRecord::Base has_and_belongs_to_many :articles end