title: build method on ruby on rails
body: <p>New to rails and I'm following the Depot project found in the Agile web development with rails 3.1. Everything was fine until I got lost when the book used the "build" method.</p>
  
  <pre><code>@cart = current_cart
  product = Product.find(params[:product_id])
  @line_item = @cart.line_items.build(product: product)
  </code></pre>
  
  <p>My google searches led me to understand that the .build method is just a cleaner way to create a row in the table (with association between tables). But on the code above, I was expecting the code would look like something like this: </p>
  
  <pre><code>@line_item = @cart.line_items.build(product_id =&gt; params[:product_id])
  </code></pre>
  
  <p>I don't understand why the author had to store the whole row of products( product = Product.find(params[:product_id])) instead of just getting the product_id...</p>
  
  <p>Is there more to it than what I can understand?</p>