Why is Object nil?

Ryo Saeba
2013-03-24T12:10:05Z

I''m receiving the

"Called id for nil, which would mistakenly be 4 -- if you really wanted
the id of nil, use object_id"

Error Message, when my controller tries to get an object''s id.

In my page users can register, login, create new game entries, rate them
and leave a review.

the create method in the ratings controller is the exact same as in the
review controller. (with different names of course)

def create
        @game = Game.find_by_id(params[:game_id])
        @rating = Rating.new(params[:rating])
        @rating.game_id = @game.id
        @rating.user_id = current_user.id
end

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?

--
Posted via http://www.ruby-forum.com/.