Sha256: 0fd4d38e716f3d99a18e9f30653819c0762e4c6a52e5398f46860a3e42cd1573

Contents?: true

Size: 976 Bytes

Versions: 1

Compression:

Stored size: 976 Bytes

Contents

module Adminpanel
  class ApplicationController < ActionController::Base
    protect_from_forgery

    inherit_resources

    include SessionsHelper
    include Adminpanel::RestActions
    include Adminpanel::GalleryzableActions

    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

1 entries across 1 versions & 1 rubygems

Version Path
adminpanel-2.0.1 app/controllers/adminpanel/application_controller.rb