Topic: Rails to pass id to foreign table

I'm working on a videogame database, where users can signup, make game
entries, rate and review them.

I have the Models: User, Game, Rating and Review. Each user can give his
own rating to any game, so I have to pass the to the
ratings.game_id in order to associate ratings to certain games.

And I would like to think that it should work the same way about posting
reviews, but every time I the shall be passed, get a Runtime

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

This is what my associations in my models look like

  has_many :reviews, dependent: :destroy
  has_many :reviewed_games, :through => :reviews, :source => :games

  has_many :reviews
  has_many :authors, :through => :reviews, :source => :users

  belongs_to :user
  belongs_to :game

This is my review controller
  def create
    @game = Game.find_by_id(params[:game_id])
    @review =[:review])
    @review.game_id =
    @review.user_id =

      flash[:success] = "review created!"
      redirect_to @review
      render 'new'

And my Form
<%= form_for(@review) do |f| %>
  <div class="field">
    <%= f.text_area :content, placeholder: "Compose new review..." %>
  <%= hidden_field_tag("game_id", %>
  <%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>

The Runtime Error occurs, once I try to open the reviews/new url. When I
dismiss the hidden_field_tag, I receive the review form, but now posting
causes the exact same error (because of the in the create

I really can't explain why this is happening, because the very same way
my whole rating feature is programmed and it works just fine.

For routing I simply use "resources :reviews", same as with ratings

Can you Guys help me out?

Last edited by SirJaySaeba (2013-04-15 16:30:15)