# Params\[hash\] and link\_to.... easy question... but I am stupid :)

**URL:** <https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901>\
**Category:** Rails\
**Created:** [April 14, 2010, 1:46am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901 "2010-04-14T01:46:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![slindsey3000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@slindsey3000](https://www.ruby-forum.com/u/slindsey3000)\
**Post date:** [April 14, 2010, 1:46am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901/1 "2010-04-14T01:46:10Z")

</div>

routes.rb

map.connect ‘:controller/:action/:id/:draw\_id’, :controller =\>  
“admin”, :action =\> “edit\_position”

In a view I have:

\<%= link\_to “#{@draw.positions[0].team}”, { :controller  
=\> :admin, :action =\> :edit\_position,  
:id  
=\>@draw.positions[0].id, :draw\_id =\> @draw.id } %\>

In my controller I do not receive the param :draw\_id in my params[]

Any thoughts? How do I do a link\_to and pass in these 2  
parameters :id and :draw\_id

Thanks!

Shawn

---

<div class="post-metadata">

**Author:** ![slindsey3000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@slindsey3000](https://www.ruby-forum.com/u/slindsey3000)\
**Post date:** [April 14, 2010, 1:55am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901/2 "2010-04-14T01:55:33Z")

</div>

On Tue, 2010-04-13 at 16:44 -0700, slindsey3000 wrote:

> ```
> :id
> 
> ```
> 
> =\>@draw.positions[0].id, :draw\_id =\> @draw.id } %\>
> 
> In my controller I do not receive the param :draw\_id in my params[]
> 
> Any thoughts? How do I do a link\_to and pass in these 2  
> parameters :id and :draw\_id

* * *

the param :draw\_id would be sent as a parameter…

[http://www.example.com/controller/action/id?draw\_id=1](http://www.example.com/controller/action/id?draw_id=1)

thus, there really is no need to represent it in routes.rb

Craig

–  
This message has been scanned for viruses and  
dangerous content by MailScanner, and is  
believed to be clean.

---

<div class="post-metadata">

**Author:** ![slindsey3000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@slindsey3000](https://www.ruby-forum.com/u/slindsey3000)\
**Post date:** [April 14, 2010, 2:02am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901/3 "2010-04-14T02:02:34Z")

</div>

It is not in my params hash though…

I initially did nothing with my routes.rb… then seeing that the only  
param I got was :id, I started playing around.

can anyone give me an example of a link\_to that sends 2 parameters to  
a controller.

This seems so silly, but I am stuck.

Thanks so much…

---

<div class="post-metadata">

**Author:** ![slindsey3000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@slindsey3000](https://www.ruby-forum.com/u/slindsey3000)\
**Post date:** [April 14, 2010, 2:54am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901/4 "2010-04-14T02:54:06Z")

</div>

link\_to “link”, :controller =\> “articles”, :id =\> id, :draw\_id =\>  
@draw.id

---

<div class="post-metadata">

**Author:** ![slindsey3000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@slindsey3000](https://www.ruby-forum.com/u/slindsey3000)\
**Post date:** [April 14, 2010, 3:35am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901/5 "2010-04-14T03:35:06Z")

</div>

Sure… but how would you access the :draw\_id in your controller?

It is not showing up in my params hash… with what you wrote I only  
get :id in the hash as well as action and controller.

---

<div class="post-metadata">

**Author:** ![slindsey3000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/aca169/32.png) [@slindsey3000](https://www.ruby-forum.com/u/slindsey3000)\
**Post date:** [April 14, 2010, 10:28am UTC](https://www.ruby-forum.com/t/params-hash-and-link-to-easy-question-but-i-am-stupid/186901/6 "2010-04-14T10:28:19Z")

</div>

On 14 April 2010 02:33, slindsey3000 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Sure… but how would you access the :draw\_id in your controller?
> 
> It is not showing up in my params hash… with what you wrote I only  
> get :id in the hash as well as action and controller.

Is draw\_id showing in the log file (log/development.log). If not then  
@draw.id is probably nil. Have a look at the html of your page (View,  
Page source or similar in your browser) and see if it is there. Also  
you could try displaying @draw.id in the page to see what it is.

By the way most think it better to insert your comments to previous  
emails inline rather than at the top. It makes it easier to follow  
the thread.

Colin
