Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

need possibility to wrap whole process inside transaction #169

Open
senid231 opened this issue Sep 30, 2019 · 1 comment
Open

need possibility to wrap whole process inside transaction #169

senid231 opened this issue Sep 30, 2019 · 1 comment

Comments

@senid231
Copy link
Member

also it will be nice to have ability to pass template_object as proc

@Fivell
Copy link
Member

Fivell commented Nov 23, 2019

current solution

      active_admin_import options

      controller do
        around_action :wrap_in_transaction, only: [:do_import]

        def wrap_in_transaction
          ApplicationRecord.transaction do
            yield
            # When error appears during ActiveAdminImport process
            # it's being rescued inside gem and adds flash error.
            # In this case we must rollback a transaction.
            # see https://github.com/activeadmin-plugins/active_admin_import/issues/169
            raise ActiveRecord::Rollback if flash[:error].present?
          end
        end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants