Method: ActiveAdmin::ResourceController::DataAccess#collection

Defined in:
lib/active_admin/resource_controller/data_access.rb

#collectionActiveRecord::Relation (protected)

Retrieve, memoize and authorize the current collection from the db. This method delegates the finding of the collection to #find_collection.

Once #collection has been called, the collection is available using either the @collection instance variable or an instance variable named after the resource that the collection is for. eg: Post => @post.

Returns:

  • (ActiveRecord::Relation)

    The collection for the index



42
43
44
45
46
47
48
# File 'lib/active_admin/resource_controller/data_access.rb', line 42

def collection
  get_collection_ivar || begin
    collection = find_collection
    authorize! Authorization::READ, active_admin_config.resource_class
    set_collection_ivar collection
  end
end