THIS DOCUMENTATION IS RATHER INCOMPLETE, I AM WORKING ON IT.
Simple add the following to your Gemfile
rails g active_import:model_converter User
This will create an model converter in the directory app/model_converters. You can read through this import file to see how the import works.
This also creates a default data file in db/active_import. This will be the CSV used for this converter.
There are three Rake tasks that allow you to use a converter on a file:
rake active_import:csv Load csv file into a model using a model converter rake active_import:excel Load excel file into a model using a model converter rake active_import:seed Seed a list of import files
rake active_import:csv FILE=user.csv CONVERTER=User CONVERTER_OPTIONS="give_admin_access=true"
In this case the file in db/active_import/user.csv would be run through the converter UserConverter. The options specified are available within the converter. In this case @options will evaluate to true.
The FILE parameter is not strictly necessary in this case either as the default file name will be an underscored value of the name of the converter.
Seeding allows you to import several files through different model converters in a single command. It involves the creation of a .seed file. Each file goes on a single line and the options are separated by pipe symbols.
user_info/user.xls | User | give_admin_access=false,send_email=true user_info/roles.xls | Role user_info/permissions.xls | UserPermission
You could save this file as db/active_import/user_info.seed and run the command like this:
rake active_import:seed SET=user_info
Note this will get the data files from a subdirectory: db/active_import/user_info. Also the top conversion uses options but as they are optional, the following two do not.
If you do not specify a set, the rake task will look for a set based on the current development environment: ie development.seed.