Many To Many (through Pivot / Junction)
Preparing your DB schema
class AddUsers < ActiveRecord::Migration[7.0]
def change
create_table :users do |t|
# "id" primary key column will also be added implicitly by Rails(ActiveRecord)
t.string :email, null: false
end
end
endclass AddTags < ActiveRecord::Migration[7.0]
def change
create_table :tags do |t|
t.string :label, null: false
end
# Use "label" as the primary key column
add_index :tags, :label, unique: true
end
endResulting Model Relations
Last updated

