PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > Magic 'show' action
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Magic 'show' action

Réponse
 
LinkBack Outils de la discussion
Vieux 19/06/2008, 12h55   #1
Alex Birkett
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Magic 'show' action

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

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

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 appreciated.

Thanks,

Alex

Attachments:
http://www.ruby-forum.com/attachment..._controller.rb

--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 19/06/2008, 14h16   #2
Eleanor McHugh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Magic 'show' action

On 19 Jun 2008, at 12:55, Alex Birkett wrote:
> 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
>
> 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
>
> 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.


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
----
raise ArgumentError unless @reality.responds_to? :reason



  Réponse avec citation
Vieux 19/06/2008, 14h49   #3
Alex Birkett
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Magic 'show' action

Eleanor McHugh wrote:
> On 19 Jun 2008, at 12:55, Alex Birkett 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
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 19/06/2008, 15h59   #4
Eleanor McHugh
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Magic 'show' action

On 19 Jun 2008, at 14:49, Alex Birkett 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

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
----
raise ArgumentError unless @reality.responds_to? :reason



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 02h16.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12339 seconds with 12 queries