Module: Cms::Fortress::ApplicationControllerMethods
- Defined in:
- lib/cms/fortress/application_controller_methods.rb
Class Method Summary collapse
Instance Method Summary collapse
- #ability_class ⇒ Object
- #after_sign_in_path_for(resource) ⇒ Object
- #after_sign_out_path_for(resource_or_scope) ⇒ Object
- #current_ability ⇒ Object
Class Method Details
.included(base) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cms/fortress/application_controller_methods.rb', line 43 def self.included(base) base.class_eval do rescue_from CanCan::AccessDenied do |ex| # if cannot view page check if can on files if controller_name.eql?('pages') if can? :view, Cms::File redirect_to admin_cms_site_files_path else redirect_to end elsif controller_name.eql?('layouts') if can? :view, Cms::Snippet redirect_to admin_cms_site_snippets_path else redirect_to end elsif controller_name.eql?('sites') if can? :view, Cms::Fortress::Role redirect_to cms_fortress_roles_path else redirect_to end else redirect_to #, :alert => ex.message end end end end |
Instance Method Details
#ability_class ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/cms/fortress/application_controller_methods.rb', line 30 def ability_class if defined?(Ability) Ability else CmsAbility end end |
#after_sign_in_path_for(resource) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/cms/fortress/application_controller_methods.rb', line 5 def after_sign_in_path_for(resource) if resource.class.eql?(Cms::Fortress::User) admin_cms_path else begin stored_location_for(resource) || send("after_sign_in_path_for_#{ resource.class.name.underscore }", resource) rescue raise "Cannot find `after_sign_in_path_for_#{ resource.class.name.underscore }` in your ApplicationController class." end end end |
#after_sign_out_path_for(resource_or_scope) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cms/fortress/application_controller_methods.rb', line 17 def after_sign_out_path_for(resource_or_scope) # request.referrer if resource_or_scope.eql?(:cms_fortress_user) admin_cms_path else begin stored_location_for(resource_or_scope) || send("after_sign_out_path_for_#{ resource_or_scope.to_s }", resource_or_scope) rescue raise "Cannot find `after_sign_out_path_for_#{ resource.class.name.underscore }` in your ApplicationController class." end end end |
#current_ability ⇒ Object
39 40 41 |
# File 'lib/cms/fortress/application_controller_methods.rb', line 39 def current_ability @current_ability ||= ability_class.new(current_cms_fortress_user) end |