Giving a rating works perfectly, but assigning the game.id to @review.game_id causes me the error…
but my relations are set, what can possibly be wrong? why is the game
object not nil when trying to create a rating, but nil when I want to
create a review?
the create method in the ratings controller is the exact same as in the @review.game_id causes me the error…
The error is saying that @game is nil. Look in development.log when
the method is called to see what params[:game_id] is set to. If you
still can’t see it then put some print statements in the method to
print the value of params[:game_id] and to show whether @game is nil.
Also have a look at the Rails Guide on debugging which will show you
techniques that you can use to debug your code.
Maybe I need an intersection table joining Reviews and games?
Is that in answer to my post? If so it does seem to address my
points. I don’t see what the reviews table has got to do with your
problem as seems to be purely an issue of looking up a game id in the
database.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.