Collection selection

This is the official documentation of the agent_ruby Ruby agent.

You may not want to import all collections from a data source.

This can be achieved by providing a whitelist or a blacklist in the options of the agent.add_datasource method.

module ForestAdminRails
  class CreateAgent
    def self.setup!
      database_configuration = Rails.configuration.database_configuration
      datasource = ForestAdminDatasourceActiveRecord::Datasource.new(database_configuration[Rails.env])

      @create_agent = ForestAdminAgent::Builder::AgentFactory.instance.add_datasource(
        datasource,
        {
          include: %w[book review],
          # You can also exclude
          exclude: %w[author ...]
        }
      )
      customize
      @create_agent.build
    end

    def self.customize
      # @create_agent.add_datasource....
    end
  end
end

Last updated