Sha256: 7c01d4ae38ffbed4a338b0222573f3feca4aab54a9fc7725ba54f6cbc0606090

Contents?: true

Size: 1016 Bytes

Versions: 2

Compression:

Stored size: 1016 Bytes

Contents

module Adminpanel
  class ApplicationController < ActionController::Base
    protect_from_forgery

    inherit_resources

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

    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

2 entries across 2 versions & 1 rubygems

Version Path
adminpanel-2.1.1 app/controllers/adminpanel/application_controller.rb
adminpanel-2.1.0 app/controllers/adminpanel/application_controller.rb