Code Monkey home page Code Monkey logo

Comments (5)

Fivell avatar Fivell commented on August 29, 2024

@hivemindunit , this gem uses activerecord-import under the hood .
Normal ActiveRecord callbacks will NOT be called when using activerecord-imports. This is because it is mass importing rows of data and doesn't necessarily have access to in-memory ActiveRecord objects.

from active_admin_import.

Fivell avatar Fivell commented on August 29, 2024

to access result of current import you can use this https://github.com/activeadmin-plugins/active_admin_import/wiki/before_batch_import-and-after_batch_import-options

where import.result is instance of this https://github.com/activeadmin-plugins/active_admin_import/blob/master/lib/active_admin_import/import_result.rb

However it contains only failed entries.

from active_admin_import.

Fivell avatar Fivell commented on August 29, 2024

@hivemindunit , to run method for each object after batch create try this snippet

after_batch_import: proc{ |import|
    Post.where(id: importer.values_at('id')).each do |post|
        post.my_method!
    end 
 }

from active_admin_import.

hivemindunit avatar hivemindunit commented on August 29, 2024

@Fivell, thank you! Id didn't work for me exactly as you suggested because I don't have ID column in my import file. I slightly modified it and it works just fine!

from active_admin_import.

Fivell avatar Fivell commented on August 29, 2024

@hivemindunit, yes any unique column or column combination can be used

from active_admin_import.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.