Confused newbe again.. with id instead of action in URL


I'm trying to generate a new action and is very confused by the error message I get. I am accessing http://localhost:3001/members/isactive/ and get this error message:

ActiveRecord::RecordNotFound in MembersController#show

Couldn't find Member with ID=isactive

How come? Shouldn't I get the isactive action + view?



We can't see the web server running on your local machine (localhost: 3001). You'll need to provide a code sample....


you’re using restful routing and you haven’t set up a route for isactive yet.


Ok, this may very well be a routing problem, but I fail to do something about it. My config/routes.rb contained just the default

ActionController::Routing::Routes.draw do |map|   map.resources :members

  map.resources :members   map.connect ':controller/:action/:id'   map.connect ':controller/:action/:id.:format'


which does not seem to include my case. But, how do I fix this? Adding map.connect ':controller/:action' either above or below the last default cases does nothing, and I cannot get an explicit

map.connect 'members/inactive', :controller => 'members', :action => 'inactive'

to get me anywere. RoR wants to map the last entry to "id" rather than action.

BTW, adding a fake ID, as in http://localhost:3001/members/inactive/1, works :slight_smile:


You need to add a custom route. Remove your 'map.resources :members' and replace it with:

map.resources :members, :collection => { :inactive => :any }

replace :any with either :get or :post, depending upon how you want to access it (or leave it as :any to allow either :get or :post)


This did the trick. Now, where do I learn about these new routes?


You can find RESTful Rails documentation everywhere on the net via google. I found these two PDF documents on it for you:

the second is a cheatsheet, so it's concise and contains only essential examples