Can not call my associate table in my view. have tried this. it is an application that only adds to the players. after the press \"start game\" and then he should come to the re
The CreateResults migration miss the player_id column.
Do belongs_to :player
in your Result class and correct the migration (or do another one).
[Edit] I wasn't clear enough : I think you inverted the relationship logic. You actually did the "one result has several players". I suppose you want that a player has several results ?
class Player
has_many :results
end
class Result
belongs_to :player
end
So you can do :
@myplayer = Player.all.first
@myplayer.results #it is an array of player's results
@myplayerresult = @myplayer.results.first
puts @myplayerresult.result
If you want a one-to-one relationship, consider replacing has_many :results
by has_one :result
and so you can do @myplayer.result
to get your result.