application_controller.rb 354 B

123456789101112131415161718
  1. # encoding:utf-8
  2. class ApplicationController < ActionController::Base
  3. protect_from_forgery
  4. layout :layout_by_resource
  5. rescue_from CanCan::AccessDenied do |exception|
  6. redirect_to root_url, :alert => exception.message
  7. end
  8. def layout_by_resource
  9. if devise_controller?
  10. "devise_layout"
  11. else
  12. "application"
  13. end
  14. end
  15. end