This project is archived and is in readonly mode.
Namespaced controller sometimes uses default layout, views
Reported by Łukasz Piestrzeniewicz | September 15th, 2008 @ 10:32 AM | in 2.x
This is quite elusive bug, happened twice on production but I wasn't able to reproduce it in development environment yet.
I have two SessionControllers. One is used for site patrons, is
available under /sessions
and uses
application.html.haml
layout. Another for admin login,
is available under /admin/sessions
and uses
admin/administration.html.haml
layout.
When server runs for some time namespaced controller starts to
use application layout instead of administration one and renders
views from app/views/sessions
rather than
app/views/admin/sessions
. After server restart
everything goes back to normal.
Relevant code snippets:
config/routes.rb
map.namespace :admin do |admin|
admin.resource :session
end
# snip...
map.resources :sessions, :collection => {:admin_new => :get,
:admin_create => :post, :auto_complete_for_user_email => :get}
app/controllers/admin/admin_controller.rb
class Admin::AdminController < ApplicationController
layout 'admin/administration'
before_filter :require_admin
def index
end
end
app/controllers/admin/sessions_controller.rb
class Admin::SessionsController < Admin::AdminController
skip_before_filter :require_admin
end
Snippet from production.log
Processing AdminController#index (for 84.186.212.124 at 2008-09-15 10:55:18) [GET]
Session ID: BAh7CzoMdXNlcl9pZDA6DnJldHVybl90bzA6DGNzcmZfaWQiJTU1NTZlYmI5
N2JkODdhMjlkZjZhYjhmZmFiZTI0YmEyOg1hZG1pbl9pZDAiCmZsYXNoSUM6
J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7BjoKZXJyb3Ii
L0NvdWxkbid0IGxvZyB5b3UgaW4gYXMgJ2FkbWluQGV4YW1wbGUuY29tJwY6
CkB1c2VkewY7CkY6FGFkbWluX3JldHVybl90byILL2FkbWlu--197369dabe2c5f5e1ca0a02f1dbbae997ba76058
Parameters: {"action"=>"index", "controller"=>"admin/admin"}
Redirected to http://beta.jobmensa.de/admin/session/new
Filter chain halted as [:require_admin] rendered_or_redirected.
Completed in 0.00692 (144 reqs/sec) | DB: 0.00168 (24%) | 302 Found [http://beta.jobmensa.de/admin]
Processing SessionsController#new (for 84.186.212.124 at 2008-09-15 10:55:18) [GET]
Session ID: BAh7CzoMdXNlcl9pZDA6DnJldHVybl90bzA6DWFkbWluX2lkMDoMY3NyZl9p
ZCIlNTU1NmViYjk3YmQ4N2EyOWRmNmFiOGZmYWJlMjRiYTIiCmZsYXNoSUM6
J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7BjoKZXJyb3Ii
L0NvdWxkbid0IGxvZyB5b3UgaW4gYXMgJ2FkbWluQGV4YW1wbGUuY29tJwY6
CkB1c2VkewY7ClQ6FGFkbWluX3JldHVybl90byILL2FkbWlu--350d8cc6aa7eb2fcca080b9f74646b44132e1215
Parameters: {"action"=>"new", "controller"=>"admin/sessions"}
Rendering template within layouts/application
Rendering sessions/new
Rendering page snippet: Layout footer contents (0.00396)
Rendering page snippet: Layout footer links (0.00382)
Completed in 0.08378 (11 reqs/sec) | Rendering: 0.07137 (85%) | DB: 0.00899 (10%) | 200 OK [http://beta.jobmensa.de/admin/session/new]
Site runs on mongrel 1.1.5 and Ruby on Rails 2.1.0
Comments and changes to this ticket
-
Łukasz Piestrzeniewicz September 23rd, 2008 @ 02:59 PM
- Tag changed from 2.1, actionpack, bug to 2.1, actionpack, bug
Bug no longer exists in Rails 2.1.1.
To reproduce in Rails 2.1.0:
- Create namespaced controller.
- Create non-namespaced controller with the same name.
- Start the server.
- Access non-namespaced controller.
- Try to access namespaced controller - request will be handled by non-namespaced controller.
When namespaced controller is accessed first it handles further requests properly, and accessing non-namespaced one has no impact.
-
Pratik December 23rd, 2008 @ 03:14 PM
- State changed from new to invalid
Closing as the issue has already been resolved.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>