Reputation: 135
I am making a ruby app that will track ping pong game stats. This is what the model for my player looks like so far
class Game < ActiveRecord::Base
#has one winner
has_one :winner,
:source => :user
#has one loser
has_one :loser,
:source => :user
belongs_to :player
alias :recorded_by :player
end
When I load the page though, I get an error saying "unknown key: source." If you cannot tell what I am doing, the model is supposed to contain two user objects, one labeled "winner" and one labeled "loser." Can anyone point out what I'm doing wrong here?
Upvotes: 1
Views: 572
Reputation: 11278
try has_one :loser, :class_name => 'User'
this is needed because rails can't guess the correct model for loser_id
:source
on the other hand is used in :through relations.
Upvotes: 2