|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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/. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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/. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|