This project is archived and is in readonly mode.

#1049 ✓invalid
Łukasz Piestrzeniewicz

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:


  map.namespace :admin do |admin|
    admin.resource :session
  # snip...
  map.resources :sessions, :collection => {:admin_new => :get,
    :admin_create => :post, :auto_complete_for_user_email => :get}


class Admin::AdminController < ApplicationController
  layout 'admin/administration'
  before_filter :require_admin

  def index


class Admin::SessionsController < Admin::AdminController
  skip_before_filter :require_admin

Snippet from production.log

Processing AdminController#index (for at 2008-09-15 10:55:18) [GET]
  Session ID: BAh7CzoMdXNlcl9pZDA6DnJldHVybl90bzA6DGNzcmZfaWQiJTU1NTZlYmI5
  Parameters: {"action"=>"index", "controller"=>"admin/admin"}
Redirected to
Filter chain halted as [:require_admin] rendered_or_redirected.
Completed in 0.00692 (144 reqs/sec) | DB: 0.00168 (24%) | 302 Found []

Processing SessionsController#new (for at 2008-09-15 10:55:18) [GET]
  Session ID: BAh7CzoMdXNlcl9pZDA6DnJldHVybl90bzA6DWFkbWluX2lkMDoMY3NyZl9p
  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 []

Site runs on mongrel 1.1.5 and Ruby on Rails 2.1.0

Comments and changes to this ticket

  • Łukasz Piestrzeniewicz

    Ł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:

    1. Create namespaced controller.
    2. Create non-namespaced controller with the same name.
    3. Start the server.
    4. Access non-namespaced controller.
    5. 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

    Pratik December 23rd, 2008 @ 03:14 PM

    • State changed from “new” to “invalid”

    Closing as the issue has already been resolved.

  • csnk

    csnk May 18th, 2011 @ 08:15 AM

    has already been factory

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=""></a>

People watching this ticket