# Configure routes.rb

**URL:** <https://www.ruby-forum.com/t/configure-routes-rb/126997>\
**Category:** Rails\
**Created:** [January 24, 2008, 12:36am UTC](https://www.ruby-forum.com/t/configure-routes-rb/126997 "2008-01-24T00:36:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheDuckman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/49beb7/32.png) [@TheDuckman](https://www.ruby-forum.com/u/TheDuckman)\
**Post date:** [January 24, 2008, 12:36am UTC](https://www.ruby-forum.com/t/configure-routes-rb/126997/1 "2008-01-24T00:36:05Z")

</div>

Just wondering if this is possible and how to configure routes.rb

Let’s say in routes.rb I have:

map.resources :products

this would allow me to use:

new\_product\_path and the url would be /product/new  
edit\_product\_path and the url would be /product/1/edit

I would like to add another method to the controller that would be  
exactly like the “new” method.

my\_method\_product\_path and the url would be /product/my\_method

I tried:

map.resources :products, :member =\> { :my\_method =\> :get}

but, the method wants a parameter like my\_method\_product\_path(0)

How would I configure the routes.rb to accomplish this task??

---

<div class="post-metadata">

**Author:** ![TheDuckman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/49beb7/32.png) [@TheDuckman](https://www.ruby-forum.com/u/TheDuckman)\
**Post date:** [January 24, 2008, 1:26am UTC](https://www.ruby-forum.com/t/configure-routes-rb/126997/2 "2008-01-24T01:26:58Z")

</div>

can you give us more information on what this action is supposed to do?

On Jan 24, 2008 10:04 AM, TheDuckman [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> edit\_product\_path and the url would be /product/1/edit  
> but, the method wants a parameter like my\_method\_product\_path(0)
> 
> How would I configure the routes.rb to accomplish this task??
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![TheDuckman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/49beb7/32.png) [@TheDuckman](https://www.ruby-forum.com/u/TheDuckman)\
**Post date:** [January 24, 2008, 3:08am UTC](https://www.ruby-forum.com/t/configure-routes-rb/126997/3 "2008-01-24T03:08:08Z")

</div>

to make a route without parameters don’t use :member.  
as ryan says it depends on what you want to do.

it could be :  
with a “new” parameter  
map.resources :products, :new =\> { :my\_method =\> :get}  
you will call it new\_my\_method\_product\_path  
or  
with a “collection” parameter  
map.resources :products, :collection =\> { :my\_method =\> :get}  
you will call it my\_method\_products\_path

---

<div class="post-metadata">

**Author:** ![TheDuckman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/49beb7/32.png) [@TheDuckman](https://www.ruby-forum.com/u/TheDuckman)\
**Post date:** [January 24, 2008, 5:46am UTC](https://www.ruby-forum.com/t/configure-routes-rb/126997/4 "2008-01-24T05:46:03Z")

</div>

I have a related question. I started off with:  
map.resources :listings  
map.resources :categories

Then I wanted to display listings that belong to a certain category at  
“/listings/category”, so I added the following to my routes:  
map.resources :listings,  
:requirements =\> { :id =\> /[0-9]/}  
map.abc ‘listings/:id’, :controller =\> ‘listings’, :action =\>  
‘show\_constrained’  
map.abc ‘listings/:id.:format’, :controller =\> ‘listings’, :action  
=\> ‘show\_constrained’

This is successful in routing requests to the right actions, but it  
gives me only one helper method for the named route ‘abc’, which then  
becomes a problem for me. Am I going about this the wrong way?
