Sha256: a96f7eb3f1d566d1186538be4b9012e1414928bec992d6c45ea7204708144d99

Contents?: true

Size: 1.14 KB

Versions: 14

Compression:

Stored size: 1.14 KB

Contents

class Admin::BaseController < ApplicationController
  rescue_from Checkin::AccessDenied, :with => :rescue_access_denied

  layout 'admin'
  authorize(:scope => :admin)

  protected

  def rescue_access_denied
    if subject.guest?
      redirect_to new_user_session_path
    else
      render :text => "Not Authorized", :status => 403
    end
  end
  
  class << self
    def responder
    ::Admin::Responder
    end
  end
  
  helper_method :singular_name,
                :plural_name,
                :resource_name,
                :collection_name,
                :current_resource_class,
                :current_resource, 
                :current_collection


  def current_resource_class
    @current_resource_class ||= controller_name.singularize.camelize.constantize
  end
  
  def resource_name
    current_resource_class.name.demodulize.underscore
  end
  
  def collection_name
    resource_name.pluralize
  end

  alias :singular_name :resource_name
  alias :plural_name :collection_name
  

  def current_resource
    instance_variable_get("@#{resource_name}")
  end

  def current_collection
    instance_variable_get("@#{collection_name}")
  end
  
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fullstack-admin-0.1.35 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.34 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.33 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.32 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.30 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.29 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.28 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.27 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.26 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.25 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.24 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.23 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.20 app/controllers/admin/base_controller.rb
fullstack-admin-0.1.19 app/controllers/admin/base_controller.rb