Last active
August 29, 2015 13:56
-
-
Save Chryus/8899641 to your computer and use it in GitHub Desktop.
Data modeling in rails: example of has_many :through migrations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCarrots < ActiveRecord::Migration | |
def change | |
create_table :carrots do |t| | |
t.string :color | |
t.timestamps | |
end | |
end | |
end | |
class CreateBunnies < ActiveRecord::Migration | |
def change | |
create_table :bunnies do |t| | |
t.string :name | |
t.timestamps | |
end | |
end | |
end | |
class CreateCommunities < ActiveRecord::Migration | |
def change | |
create_table :communities do |t| | |
t.integer :carrot_id | |
t.integer :bunny_id | |
t.timestamps | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment