# Routes with params

**URL:** <https://www.ruby-forum.com/t/routes-with-params/145379>\
**Category:** Rails\
**Created:** [August 8, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/routes-with-params/145379 "2008-08-08T16:18:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [August 8, 2008, 4:18pm UTC](https://www.ruby-forum.com/t/routes-with-params/145379/1 "2008-08-08T16:18:45Z")

</div>

Hey all,

my code looks like:

\<%= link\_to ‘add’, :controller =\> ‘item’, :action =\> ‘add\_me’, :title =\>  
posts.title, :description =\> posts.description %\>

I already added

map.connect ‘:controller/:action’

to my routes.rb, but i always get:  
No route matches “/item/add\_me” with {:method=\>:get}

Or should my link look something different?

Thanks for your help!

Steph

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [August 8, 2008, 5:28pm UTC](https://www.ruby-forum.com/t/routes-with-params/145379/2 "2008-08-08T17:28:32Z")

</div>

Hey,

i strongly suggest you read about RESTful design and controllers in  
Rails. You should find plenty of good tutorials on google.

I don’t know how you created the controller but it is usualy used in  
plural. So if you create a model Item, the created controller is  
called itemS\_controller.rb. This means you should try accessing /items/  
add\_me (why add\_me and not new?) rather than /item/add\_me.

The line you wrote in the routes searches for any controller matching  
first “parameter” in url and action second. I’m (almost) sure your  
controller is in plural and this is the reason why the route doesn’t  
work.

But you should consider making a custom route like this:

map.items “items/:action”, :controller =\> “items”

Then in your views you can easily make links like this:

\<%= link\_to ‘All items’, items\_path %\>

Hope it helps! And hey… find and read some tutorials on restful  
design!

On 8 avg., 16:18, Stephan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [August 8, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/routes-with-params/145379/3 "2008-08-08T17:49:01Z")

</div>

Hey, thanks for your reply.

I think i dont make clear what i want to do 🙂

I try to add an item with custom params. I wrote my own action add\_me  
where i create an new item and filled it with this params (:title,  
:description).

(Or should i call new and then update?)

The params comes from a loop over RSSReader posts, and add\_me is to add  
the rss content to my database.

greetings 🙂

---

<div class="post-metadata">

**Author:** ![pure](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ab097/32.png) [@pure](https://www.ruby-forum.com/u/pure)\
**Post date:** [August 8, 2008, 6:58pm UTC](https://www.ruby-forum.com/t/routes-with-params/145379/4 "2008-08-08T18:58:10Z")

</div>

If you can, pick the book “The Rails Way” by Obie F… I just  
read this exact chapter last night and explains is super good detail,  
exactly what you are wanting/trying to do.

He explains custom routes, named routes, etc. very well - along with  
it being an excellent book in many other areas.

–Cory

On Aug 8, 10:18 am, Stephan M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
