You are correct.
Bet model would have two
belongs_to associations (one for the creator and one for the backer or however you'd like to call them):
class Bet < ApplicationRecord belongs_to :creator, class_name: 'User' belongs_to :backer, class_name: 'User' end
bets table would need two columns for the user's id. With the above snippet, you would need a
creator_id and a
And then if you wanted to access the bets from a user (created and backed bets for example) you would create two
has_many associations on the
class User < ApplicationRecord has_many :created_bets, foreign_key: 'creator_id', class_name: 'Bet' has_many :backed_bets, foreign_key: 'backer_id', class_name: 'Bet' end
Hope that makes sense.