Skip to content

Instantly share code, notes, and snippets.

@kenmazaika
Created May 6, 2015 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kenmazaika/44e8d84a2ea8235b857a to your computer and use it in GitHub Desktop.
Save kenmazaika/44e8d84a2ea8235b857a to your computer and use it in GitHub Desktop.
Populate the Board of a Chess Game
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
@kenmazaika
Copy link
Author

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):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment