rails 3: layout for namespaced routes

I usually have a Base controller class in my namespace, and then have all controllers in that namespace inherit from it. That allows me to put common, namespace specific code in Base and all the controllers in that namespace can take advantage. For example:

class Admin::BaseController < ApplicationController
  layout 'admin'
  before_filter :require_admin_user
end

class Admin::WidgetsController < Admin::BaseController
  # inherits the 'admin' layout and requires an admin user
end

Leave a Comment

tech