title: undefined method `id' for #<ActiveRecord::Relation []>
body: <p>I can't get id value from a model. </p>
  
  <p>My code:</p>
  
  <pre><code>session["game_space"]   = params[:game_space_id]
  
  @player_space = PlayerSpace.where(game_space_id: session["game_space"], user_id: current_user.id)
  
  session["player_space"] = @player_space.id #&lt;&lt;&lt;&lt;===== The error occurs here
  
  redirect_to "show",:id =&gt; @player_space.id
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>Error: undefined method `id' for #&lt;ActiveRecord::Relation []&gt;
  </code></pre>
  
  <p>Can you help me on this?</p>