module <%= class_name %> class ApplicationController < ::ApplicationController include ::Susanin include ::MuteAction include ::StateMachineAbilities include ::Paginator <%- if @kind.api? -%> include ::<%= class_name %>::CurrentIdentity <%- end -%> <%- unless @access.cancan? -%> include ::MockAuthorization <%- end -%> <%- if @access.cancan? -%> include CanCan::ControllerAdditions include <%= class_name %>::CurrentIdentity <%- end -%> meta_for(:title, :suffix, Settings.application.name) <%- if @kind.api? -%> respond_to :json self.responder = <%= class_name %>::ApiResponder <%- end -%> susanin do [ # [:root, ->(r) { [(signed_in? ? :client : :public), r] }] ] end <%- if @access.cancan? && @begin_chain -%> before_filter :authorize_<%= @begin_chain -%>! <%- end -%> <%- if @begin_chain -%> helper_method :<%= @begin_chain -%> <%- end -%> <%- if @kind.api? -%> rescue_from ActiveRecord::RecordNotFound do |exception| render json: { error: exception.message }, status: 404 end rescue_from ParamsConverter::ParamsConverterError do |exception| render json: { error: exception.message }, status: 401 end <%- end -%> <%- if @access.cancan? -%> check_authorization rescue_from CanCan::AccessDenied do |exception| redirect_to main_app.root_url, :alert => exception.message end <%- end -%> <%- if @access.http? -%> http_basic_authenticate_with name: Settings.admin.name, password: Settings.admin.password <%- end -%> protected <%- if @begin_chain -%> def title_prefix <%= @begin_chain -%>.name end <%- end -%> <%- if @begin_chain -%> def <%= @begin_chain %> @<%= @begin_chain %> ||= current_user.try(:company) end <%- end -%> <%- if @begin_chain -%> def begin_of_association_chain <%= @begin_chain %> end <%- end -%> <%- if @begin_chain -%> def current_ability @current_ability ||= <%= class_name %>::Ability.new(current_user, <%= @begin_chain -%>) end <%- end -%> <%- if @access.cancan? && @begin_chain -%> def authorize_<%= @begin_chain %>! authorize! :login, <%= @begin_chain %> end <%- end -%> end end