# encoding:utf-8 class ApplicationController < ActionController::Base protect_from_forgery layout :layout_by_resource rescue_from CanCan::AccessDenied do |exception| redirect_to root_url, :alert => exception.message end def layout_by_resource if devise_controller? "devise_layout" else "application" end end end