Sha256: f4281c13a1b1a2142b73fb92e63469fa227057bb4a2e1dbbb129a8a8ca203663

Contents?: true

Size: 820 Bytes

Versions: 16

Compression:

Stored size: 820 Bytes

Contents

module Gaku
  module Admin
    class BaseController < CoreController

      self.responder = Gaku::AppResponder
      respond_to :html

      layout :resolve_layout

      before_filter :authorize_admin

      private

      def current_ability
        @current_ability ||= Gaku::AdminAbility.new(current_user)
      end

      def resolve_layout
        case action_name
        when 'index'
          'gaku/layouts/admin/index'
        when 'show'
          'gaku/layouts/admin/show'
        else
          'gaku/layouts/admin/gaku'
        end
      end

      protected

      def authorize_admin
        begin
          record = model_class.new
        rescue
          record = Object.new
        end
        authorize! :admin, record
        authorize! params[:action].to_sym, record
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_admin-0.3.0 app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.3.0.pre.4 app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.3.0.pre.3 app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.3.0.pre.2 app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.3.0.pre.1 app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.3.0.pre.0 app/controllers/gaku/admin/base_controller.rb
gaku-0.2.4 admin/app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.2.4 app/controllers/gaku/admin/base_controller.rb
gaku-0.2.3 admin/app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.2.3 app/controllers/gaku/admin/base_controller.rb
gaku-0.2.2 admin/app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.2.2 app/controllers/gaku/admin/base_controller.rb
gaku-0.2.1 admin/app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.2.1 app/controllers/gaku/admin/base_controller.rb
gaku-0.2.0 admin/app/controllers/gaku/admin/base_controller.rb
gaku_admin-0.2.0 app/controllers/gaku/admin/base_controller.rb