Sha256: be8fcaf8302477290562d8785250a62a2bc1ee848d54b3e084cad316f17d1faa

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true
module ActiveAdmin
  class ResourceController < BaseController

    # This module deals with scoping entire controllers to a relation
    module Scoping
      extend ActiveSupport::Concern

      protected

      # Override the default InheritedResource #begin_of_association_chain to allow
      # the scope to be defined in the active admin configuration.
      #
      # If scope_to is a proc, we eval it, otherwise we call the method on the controller.
      #
      # Collection can be scoped conditionally with an :if or :unless proc.
      def begin_of_association_chain
        return nil unless active_admin_config.scope_to?(self)
        helpers.render_in_context(self, active_admin_config.scope_to_method)
      end

      # Overriding from InheritedResources::BaseHelpers
      #
      # Returns the method for the association chain when using
      # the scope_to option
      def method_for_association_chain
        active_admin_config.scope_to_association_method || super
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
activeadmin-4.0.0.beta14 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta13 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta12 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta11 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta10 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta9 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta8 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta7 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta6 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta5 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta4 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta3 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta2 app/controllers/active_admin/resource_controller/scoping.rb
activeadmin-4.0.0.beta1 app/controllers/active_admin/resource_controller/scoping.rb