title: Rails - routing error with friendly_id slug and nested resource
body: <p>I am trying to route to a nested resource from a resource using friendly_id. Below is the code:</p>
  
  <p>routes.rb:</p>
  
  <pre><code> resources :products do
     resources :reviews, except: [:index]
   end
  </code></pre>
  
  <p>rake routes:</p>
  
  <pre><code>new_product_review GET        /products/:product_id/reviews/new(.:format)
  </code></pre>
  
  <p>controller:</p>
  
  <pre><code>@review = Review.new(product_id: params[:product_id])
  </code></pre>
  
  <p>view button on the specific product page:</p>
  
  <pre><code>&lt;%= link_to(raw("&lt;button&gt;Write a Review&lt;/button&gt;"), new_product_review_path(@review.product_id, @review) ) %&gt;
  </code></pre>
  
  <p>product URL:</p>
  
  <pre><code>http://localhost:3000/products/light-saber #just kidding
  </code></pre>
  
  <p>However, I am getting the error of:</p>
  
  <pre><code>undefined method `product_id'
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>Update -----</p>
  
  <p>Now in my controller I have:</p>
  
  <pre><code>before_filter :setup_product
  
  @review = @product.reviews.new
  
  def setup_product
      @product = Product.find(params[:product_id])
  end
  </code></pre>
  
  <p>I am still getting the same error though. My question explicitly is, since my URL is not passing in an integer ID because I am using friendly_id, is the param structured so that the controller can retrieve the product like I want?</p>
  
  <p>UPDATE:</p>
  
  <p>Now I am getting this error:</p>
  
  <pre><code>No route matches {:action=&gt;"new", :controller=&gt;"reviews", :product=&gt;nil}
  </code></pre>
  
  <p>I get this when I change the code in my Product page to:</p>
  
  <pre><code>&lt;%= link_to(raw("&lt;button&gt;Write a Review&lt;/button&gt;"), new_product_review_path(@review) ) %&gt;
  </code></pre>