Skip to content

Instantly share code, notes, and snippets.

@jonallured
Created March 22, 2012 00:01
Show Gist options
  • Save jonallured/2154306 to your computer and use it in GitHub Desktop.
Save jonallured/2154306 to your computer and use it in GitHub Desktop.
Modeling that app
class Player < ActiveRecord::Base
has_many :initiated_challenges, foreign_key: 'player_one_id', class_name: 'Challenge'
has_many :accepted_challenges, foreign_key: 'player_two_id', class_name: 'Challenge'
end
class Challenge < ActiveRecord::Base
belongs_to :player_one, class_name: 'Player'
belongs_to :player_two, class_name: 'Player'
has_many :games
end
class Game < ActiveRecord::Base
belongs_to :challenge
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment