Configuring routes

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

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.

This change though breaks the show action of the form - http://<domain>/projects/1

link_to('Project', project)

Anyone has any other ideas?

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

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