-
Notifications
You must be signed in to change notification settings - Fork 101
skip CSV columns
Peter edited this page Sep 11, 2019
·
3 revisions
active_admin_import has the ability to skip CSV columns (Available from 3.1.0 version).
This is useful when the CSV file has some unnecessary columns.
For example you have a CSV file with columns "Name", "Last name" and "Age". And your database table does not have an "age" column.
ActiveAdmin.register Post
active_admin_import before_batch_import: lambda { |importer|
importer.batch_slice_columns(['name', 'last_name'])
}
end
Another trick: importer.batch_slice_columns(Author.column_names)
allows you to pass all columns from table. In this case importer will use only columns listed both in CSV
and Author.columns_names
.