# Configuring routes

**URL:** <https://www.ruby-forum.com/t/configuring-routes/132915>\
**Category:** Rails\
**Created:** [March 25, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/configuring-routes/132915 "2008-03-25T19:45:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KoPoS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@KoPoS](https://www.ruby-forum.com/u/KoPoS)\
**Post date:** [March 25, 2008, 7:45pm UTC](https://www.ruby-forum.com/t/configuring-routes/132915/1 "2008-03-25T19:45:12Z")

</div>

Hi RoR gurus,

For my project, I have been trying to create the resources with the  
following urls:  
hxxp://domain/projects/active [for active projects]  
hxxp://domain/projects/archived [for archived projects]

Subsequently, I created the public methods active and archived in the  
ProjectController and created the related views.

I also added the following route in the routes.rb

- map.connect “:controller/:action”  
to the already existing default routes.

However when I click on the links for the active and archived  
projects, it throws me an error ‘Couldn’t find Project with  
ID=active’.

Am I missing something? Or is this sort of thing not permitted and we  
are expected to use only the 7 golden actions?

TiA  
KoPoS

---

<div class="post-metadata">

**Author:** ![KoPoS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@KoPoS](https://www.ruby-forum.com/u/KoPoS)\
**Post date:** [March 25, 2008, 8:04pm UTC](https://www.ruby-forum.com/t/configuring-routes/132915/2 "2008-03-25T20:04:42Z")

</div>

Mea Culpa.

I had completely forgotten about the default routes created by the  
map.resources method. To move around the error, I had to just add my  
route right at the top.

The code works like a charm now!  
Cheers.

---

<div class="post-metadata">

**Author:** ![KoPoS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@KoPoS](https://www.ruby-forum.com/u/KoPoS)\
**Post date:** [March 25, 2008, 8:28pm UTC](https://www.ruby-forum.com/t/configuring-routes/132915/3 "2008-03-25T20:28:22Z")

</div>

This change though breaks the show action of the form

- http:///projects/1

> > link\_to(‘Project’, project)

Anyone has any other ideas?

---

<div class="post-metadata">

**Author:** ![KoPoS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@KoPoS](https://www.ruby-forum.com/u/KoPoS)\
**Post date:** [March 26, 2008, 12:03am UTC](https://www.ruby-forum.com/t/configuring-routes/132915/4 "2008-03-26T00:03:06Z")

</div>

KoPoS wrote:

> I also added the following route in the routes.rb
> 
> - map.connect “:controller/:action”  
> to the already existing default routes.

Instead of this, add your actions to the existing resources for  
projects:

map.resources :projects, :collection =\> [:active, :archived]

This will add them as special cases under /projects and assume there is  
no specific id to operate on.

For more information, take a look at:

[http://api.rubyonrails.com/classes/ActionController/Resources.html#M000308](http://api.rubyonrails.com/classes/ActionController/Resources.html#M000308)

This will give you details about the :collection and :member options to  
resources and also how to restrict these actions to particular HTTP  
methods.

---

<div class="post-metadata">

**Author:** ![KoPoS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@KoPoS](https://www.ruby-forum.com/u/KoPoS)\
**Post date:** [March 26, 2008, 5:51am UTC](https://www.ruby-forum.com/t/configuring-routes/132915/5 "2008-03-26T05:51:42Z")

</div>

Mark,  
Many thanks for the help. Your tip worked perfectly!

Although I did read the API, I missed the fine print ☹ Many thanks  
once again - will be more careful now on and do my homework before  
posting a question to the group!

On Mar 26, 4:03 am, Mark B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
