Sha256: a6ad2949be94a7d2ee7d513de716a3da5fc2e91ebd97be4535ea27399620bc25

Contents?: true

Size: 1.09 KB

Versions: 3

Compression:

Stored size: 1.09 KB

Contents

module Adminpanel
  class ApplicationController < ActionController::Base
    protect_from_forgery
    inherit_resources
    authorize_resource

    layout 'admin'

    before_filter :signed_in_user, :set_model, :strong_params_for_cancan

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

  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

3 entries across 3 versions & 1 rubygems

Version Path
adminpanel-2.2.5 app/controllers/adminpanel/application_controller.rb
adminpanel-2.2.4 app/controllers/adminpanel/application_controller.rb
adminpanel-2.2.3 app/controllers/adminpanel/application_controller.rb