# Passing params - routes

**URL:** <https://www.ruby-forum.com/t/passing-params-routes/133319>\
**Category:** Rails\
**Created:** [March 30, 2008, 4:40am UTC](https://www.ruby-forum.com/t/passing-params-routes/133319 "2008-03-30T04:40:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [March 30, 2008, 4:40am UTC](https://www.ruby-forum.com/t/passing-params-routes/133319/1 "2008-03-30T04:40:14Z")

</div>

I think routes are messing up data that I am trying to pass between  
showing  
a product and entering a review.

In the product/show view I have:

\<%= link\_to ‘Add a Review’, new\_review\_path, :xyz =\> @product.id %\>

Inspecting the params of review/new there is nothing but  
{“action”=\>“new”,  
“controller”=\>“reviews”}

–

Then again, I could be way off in the original link\_to statement.

The code is pretty much stock stuff.

Any ideas?

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [March 30, 2008, 4:47am UTC](https://www.ruby-forum.com/t/passing-params-routes/133319/2 "2008-03-30T04:47:15Z")

</div>

\<%= link\_to ‘Add a Review’, new\_review\_path(@product, :xyz =\>  
@product.id)  
%\>

On Sun, Mar 30, 2008 at 8:09 AM, Sunny B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [March 30, 2008, 5:09am UTC](https://www.ruby-forum.com/t/passing-params-routes/133319/3 "2008-03-30T05:09:32Z")

</div>

bala kishore pulicherla wrote:

> \<%= link\_to ‘Add a Review’, new\_review\_path(@product, :xyz =\>  
> @product.id) %\>

I can’t see the routes.rb, but ain’t that just

new\_review\_path(@product.id)

?

–  
Phlip

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [March 30, 2008, 5:15am UTC](https://www.ruby-forum.com/t/passing-params-routes/133319/4 "2008-03-30T05:15:59Z")

</div>

Thanks, I got it to work with the following:

In the view sending the params information:  
\<%= link\_to ‘Add a Review’, new\_review\_path(:product =\> @product.id)%\>

In the view receiving the params information and passing it to the  
controller.  
\<%= f.hidden\_field :product\_id, :value =\> params[:product]%\>

On Sat, Mar 29, 2008 at 10:46 PM, bala kishore pulicherla \<

---

<div class="post-metadata">

**Author:** ![sunfish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/96bed5/32.png) [@sunfish](https://www.ruby-forum.com/u/sunfish)\
**Post date:** [March 30, 2008, 5:29am UTC](https://www.ruby-forum.com/t/passing-params-routes/133319/5 "2008-03-30T05:29:28Z")

</div>

opz i forgot to post some thing

in routes.rb  
map.resources :products.each do |product|  
product.resource :reviews  
end

and in the view  
\<%= link\_to ‘Add a Review’, new\_product\_reviews\_path(@product,:product\_d  
=\>  
@product.id)%\>

🙂

On Sun, Mar 30, 2008 at 8:45 AM, Sunny B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
