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

**URL:** <https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854>\
**Category:** Rails\
**Created:** [March 3, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854 "2008-03-03T23:11:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 3, 2008, 11:11pm UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/1 "2008-03-03T23:11:24Z")

</div>

Hi,

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/](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?

/Fredrik

–  
“Give up learning, and put an end to your troubles.”

---

<div class="post-metadata">

**Author:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 3, 2008, 11:49pm UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/2 "2008-03-03T23:49:02Z")

</div>

Frerik,

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

Ken

---

<div class="post-metadata">

**Author:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 4, 2008, 3:29am UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/3 "2008-03-04T03:29:25Z")

</div>

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

On Tue, Mar 4, 2008 at 9:18 AM, Ken [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > /Fredrik
> > 
> > –  
> > “Give up learning, and put an end to your troubles.”

–  
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:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 4, 2008, 7:46am UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/4 "2008-03-04T07:46:12Z")

</div>

On 3/4/08, Fredrik K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> map.resources :members  
> map.connect ‘:controller/:action/:id’  
> map.connect ‘:controller/:action/:id.:format’
> 
> end
> 
> 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

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)

---

<div class="post-metadata">

**Author:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 4, 2008, 7:39am UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/5 "2008-03-04T07:39:10Z")

</div>

Hi,

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’

end

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](http://localhost:3001/members/inactive/1),  
works 🙂

/Fredrik

On Tue, Mar 4, 2008 at 3:28 AM, Ryan B. (Radar)  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > 3001). You’ll need to provide a code sample…
> > 
> > >
> 
> Feel free to add me to MSN and/or GTalk as this email.
> 
> >

–  
“Give up learning, and put an end to your troubles.”

---

<div class="post-metadata">

**Author:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 4, 2008, 4:17pm UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/6 "2008-03-04T16:17:07Z")

</div>

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

[http://www.b-simple.de/download/restful\_rails\_en.pdf](http://www.b-simple.de/download/restful_rails_en.pdf)

> **[REST-cheatsheet.pdf](https://topfunky.com/clients/peepcode/REST-cheatsheet.pdf)**
>
> 78.73 KB

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

---

<div class="post-metadata">

**Author:** ![Fredrik\_K](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/bc79bd/32.png) [@Fredrik\_K](https://www.ruby-forum.com/u/Fredrik_K)\
**Post date:** [March 4, 2008, 9:22am UTC](https://www.ruby-forum.com/t/confused-newbe-again-with-id-instead-of-action-in-url/130854/7 "2008-03-04T09:22:51Z")

</div>

Exellent!

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

/Fredrik

On Tue, Mar 4, 2008 at 7:45 AM, Mike G. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > map.resources :members
> 
> >

–  
“Give up learning, and put an end to your troubles.”
