# Passing Arguments to an Action

**URL:** <https://www.ruby-forum.com/t/passing-arguments-to-an-action/87645>\
**Category:** Rails\
**Created:** [March 4, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/passing-arguments-to-an-action/87645 "2007-03-04T21:32:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [March 4, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/passing-arguments-to-an-action/87645/1 "2007-03-04T21:32:43Z")

</div>

I have spent a fair amount of time searching to find information on  
how one would pass arguments to an action (presumably some sort of URL  
appendage). It would seem to me that that would be something that  
would be done quite frequently. Judging from the extremely small  
amount of information that I recovered, I think that I again must be  
bucking the Rails way of doing things. So, the question is: If  
passing arguments to an action is something that is frequently done in  
Rails, how does one do it? It that isn’t the case because I am  
missing something, could someone please clue me in on what I’m  
missing.

Thanks for any input.

```
   ... doug
```

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [March 4, 2007, 9:48pm UTC](https://www.ruby-forum.com/t/passing-arguments-to-an-action/87645/2 "2007-03-04T21:48:44Z")

</div>

> I have spent a fair amount of time searching to find information on  
> how one would pass arguments to an action (presumably some sort of URL  
> appendage). It would seem to me that that would be something that  
> would be done quite frequently. Judging from the extremely small  
> You can do \<%= link\_to “Pass some  
> arguments”,:controller=\>“mycontroller”,:action=\>“myaction”,:id=\>35,:colour=\>“green”,:flavour=\>“orange”  
> %\>

This will use config/routes.rb to figure out how to structure the  
actual URL. If you haven’t customised it, you’ll get /controller/  
myaction/35?colour=green&flavour=orange.

Gwyn.

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [March 4, 2007, 10:31pm UTC](https://www.ruby-forum.com/t/passing-arguments-to-an-action/87645/3 "2007-03-04T22:31:51Z")

</div>

Maybe you could integrate a small solution on how to use those  
arguments later on?

---

<div class="post-metadata">

**Author:** ![doug](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dbc845/32.png) [@doug](https://www.ruby-forum.com/u/doug)\
**Post date:** [March 5, 2007, 9:20am UTC](https://www.ruby-forum.com/t/passing-arguments-to-an-action/87645/4 "2007-03-05T09:20:48Z")

</div>

> Maybe you could integrate a small solution on how to use those  
> arguments later on?  
> Sorry, I should’ve mentioned - the values will be accessible in the  
> ‘params’ hash:

params[:id] == 35  
params[:colour] == “green”  
params[:flavour] == “orange”

Gwyn.
