Last active
May 4, 2016 11:32
-
-
Save dcmorse/1f82cd6d6ab3dd0277bd844f29a1e47e to your computer and use it in GitHub Desktop.
GameLog Rails Demo
This file contains 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
echo lets practice has-and-belongs-to-many-relationships in rails | |
echo lets create a record of which players know how to play which games | |
rails new gamelog | |
cd gamelog/ | |
rake db:create | |
rails generate model Player name:string | |
rails generate model Game name:string | |
echo add has_and_belongs_to_many calls to both models | |
echo see http://guides.rubyonrails.org/association_basics.html#the-has-and-belongs-to-many-association for details | |
echo this next command isnt what I want because it doesnt create .players and .games methods | |
rails generate model GamePlayer game:references player:references --pretend | |
echo instead use this - which creates a join table thats not addressable by GamePlayer.all | |
rails generate migration CreateJoinTableGamePlayer game player | |
echo TODO discuss indicies | |
echo TODO dependent destroy | |
rake db:migrate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment