Created
May 6, 2015 18:45
-
-
Save kenmazaika/44e8d84a2ea8235b857a to your computer and use it in GitHub Desktop.
Populate the Board of a Chess Game
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
class Game < ActiveRecord::Base | |
# all the associations, etc. | |
after_create :populate_board! | |
def populate_board! | |
# this should create all 32 pieces with their initial X/Y coordinates. | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
End result should look something like this (the last piece being king doesn't matter, but you can see that it populates 32 items with correct initial positions):