Verified Commit 49410bb5 authored by Alexis Reigel's avatar Alexis Reigel
Browse files

document transaction support

parent b7eb2160
......@@ -74,6 +74,47 @@
# => 3
### Transactions
When setting `transaction true` no record is inserted if any one of them has an error.
class UserImporter < Excelsior::Importer
# declare the source file
source "static/ftp/users.xlsx"
# only insert all rows if none of them have an error
transaction true
# declare the mapping
map "First Name", to: :firstname
map "Last Name", to: :lastname
map "E-Mail", to: :email
If a block is passed to `run` the block needs to raise an error in order to
roll back the transaction.
This means that the following will trigger a rollback if the model is not
```ruby do |row|
On the other hand, the following won't trigger a rollback if the model is
```ruby do |row|
### Extended API
You may want to pass an excel file per instance. You can also define your own
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment