# Magic 'show' action

**URL:** <https://www.ruby-forum.com/t/magic-show-action/140879>\
**Category:** Ruby\
**Created:** [June 19, 2008, 1:56pm UTC](https://www.ruby-forum.com/t/magic-show-action/140879 "2008-06-19T13:56:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![trib4lmaniac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de053/32.png) [@trib4lmaniac](https://www.ruby-forum.com/u/trib4lmaniac)\
**Post date:** [June 19, 2008, 1:56pm UTC](https://www.ruby-forum.com/t/magic-show-action/140879/1 "2008-06-19T13:56:45Z")

</div>

I can’t understand why my action, ‘login’ is being redirected to ‘show’  
with login passed as an ‘id’.

So when I go to to the url [http://localhost:3000/users/login](http://localhost:3000/users/login)

Development.log shows:  
Processing UsersController#show (for 127.0.0.1 at 2008-06-19 12:45:04)  
[GET]  
Session ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxx  
Parameters: {“action”=\>“show”, “id”=\>“login”, “controller”=\>“users”}

When I got to the url: [http://localhost:3000/users/login/1](http://localhost:3000/users/login/1)

Development.log shows:  
Processing UsersController#login (for 127.0.0.1 at 2008-06-19 12:42:20)  
[GET]  
Session ID: xxxxxxxxxxxxxxxxxxxxxxxxxxxx  
Parameters: {“action”=\>“login”, “id”=\>“1”, “controller”=\>“users”}

and the login page loads.

I’ve grepped the whole project and I can’t find reference to the ‘show’  
action anywhere.

My controller is attached.

Any help appreciated.

Thanks,

Alex

---

<div class="post-metadata">

**Author:** ![trib4lmaniac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de053/32.png) [@trib4lmaniac](https://www.ruby-forum.com/u/trib4lmaniac)\
**Post date:** [June 19, 2008, 3:18pm UTC](https://www.ruby-forum.com/t/magic-show-action/140879/2 "2008-06-19T15:18:21Z")

</div>

On 19 Jun 2008, at 12:55, Alex B. wrote:

> Parameters: {“action”=\>“show”, “id”=\>“login”, “controller”=\>“users”}  
> and the login page loads.
> 
> I’ve grepped the whole project and I can’t find reference to the  
> ‘show’  
> action anywhere.
> 
> My controller is attached.

You’ll probably get a more useful answer from the rails mailing list,  
but at a rough guess I’d suggest that you read your routes.rb file and  
add a named route for your login controller.

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason

---

<div class="post-metadata">

**Author:** ![trib4lmaniac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de053/32.png) [@trib4lmaniac](https://www.ruby-forum.com/u/trib4lmaniac)\
**Post date:** [June 19, 2008, 3:50pm UTC](https://www.ruby-forum.com/t/magic-show-action/140879/3 "2008-06-19T15:50:38Z")

</div>

Eleanor McHugh wrote:

> On 19 Jun 2008, at 12:55, Alex B. wrote:
> 
> > Parameters: {“action”=\>“show”, “id”=\>“login”, “controller”=\>“users”}  
> > and the login page loads.
> > 
> > I’ve grepped the whole project and I can’t find reference to the  
> > ‘show’  
> > action anywhere.
> > 
> > My controller is attached.
> 
> You’ll probably get a more useful answer from the rails mailing list,  
> but at a rough guess I’d suggest that you read your routes.rb file and  
> add a named route for your login controller.

Hi Eleanor,

Thanks for you response, I’ll have to subscribe to the list.

I’ve fixed the problem by commenting out this line in routes.rb:  
map.resources :users

I still don’t understand where the action named ‘show’ comes from  
though.

Alex

---

<div class="post-metadata">

**Author:** ![trib4lmaniac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/9de053/32.png) [@trib4lmaniac](https://www.ruby-forum.com/u/trib4lmaniac)\
**Post date:** [June 19, 2008, 5:01pm UTC](https://www.ruby-forum.com/t/magic-show-action/140879/4 "2008-06-19T17:01:52Z")

</div>

On 19 Jun 2008, at 14:49, Alex B. wrote:

> I’ve fixed the problem by commenting out this line in routes.rb:  
> map.resources :users
> 
> I still don’t understand where the action named ‘show’ comes from  
> though.

I’m not a Rails expert so I’m sure someone will step in and correct  
the following ;p

When you use map.resource Rails creates a set of RESTful routes for  
the resource in question, so when you hit the URL /users/login/ it’s  
treating login as the parameter to pass to the show method of the  
UsersController controller as opposed to looking for the  
Users::LoginController that you intend.

A simple solution would be to define a named route for /users/login/  
prior to map.resource :users as the named route would take precedence,  
however if you’re looking to make your application RESTful a better  
choice of URL scheme might be /session/[create|show|list|etc.] and  
treat the session itself as a RESTful entity.

Hopefully that’s intelligible 🙂

Ellie

## Eleanor McHugh Games With Brains [http://slides.games-with-brains.net](http://slides.games-with-brains.net)

raise ArgumentError unless @reality.responds\_to? :reason
