Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Custom parameters

Ernesto García edited this page Feb 14, 2014 · 1 revision

Importers support receiving custom parameters. These will be available during the import process.

The following code makes an example on how to use this feature.

EmployeeImporter.import('/path/to/file.xls', params: { owner_id: current_user.id })

Then in the importer class:

class EmployeeImporter < ActiveImporter::Base
  imports Employee

  on :row_processing do
    model.owner_id = params[:owner_id]
  end
end

The params object does not need to be a hash, but this is the most common use, because it allows to pass several named parameters, all available during the import process.