Sha256: 923722d571b4b3d1830e21a17a313ffed40fb21cc3f616a9b313917113424bcd

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

module Adminpanel
  class ApplicationController < ActionController::Base
    protect_from_forgery

    inherit_resources

    include SessionsHelper
    include Adminpanel::RestActions
    include Adminpanel::GalleryzableActions
    include Adminpanel::FacebookActions
    include Adminpanel::SitemapActions

    layout 'admin'

    before_filter :signed_in_user, :set_model, :strong_params_for_cancan

  private
    def strong_params_for_cancan
      resource = controller_name.singularize.to_sym
      method = "#{resource}_params"
      params[resource] &&= send(method) if respond_to?(method, true)
    end

    rescue_from CanCan::AccessDenied do |exception|
      sign_out
      redirect_to signin_path, :alert => I18n.t('authentication.not_authorized')
    end

    def signed_in_user
      redirect_to signin_url, :notice => I18n.t('authentication.welcome') unless signed_in?
    end

    def set_model
      @model = params[:controller].classify.constantize
    end

    def handle_unverified_request
      sign_out
      super
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
adminpanel-2.1.7 app/controllers/adminpanel/application_controller.rb
adminpanel-2.1.6 app/controllers/adminpanel/application_controller.rb
adminpanel-2.1.5 app/controllers/adminpanel/application_controller.rb
adminpanel-2.1.3 app/controllers/adminpanel/application_controller.rb
adminpanel-2.1.2 app/controllers/adminpanel/application_controller.rb