Giter Club home page Giter Club logo

Comments (8)

Fivell avatar Fivell commented on July 30, 2024

all invalid instances are stored in import.result[:failed] and you can have access to it in after_import hook. However I didn't try this behaviour , I will check ASAP if it is possible, but at least now you can try with after_import hook

from active_admin_import.

stonehz avatar stonehz commented on July 30, 2024

👍 that's great.. I can then combine it with a mailer or pass it as a flash error message.

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

I added support to redefine messages processing and so on. You can try

add to Gemfile

gem "active_admin_import", git: 'https://github.com/Fivell/active_admin_import.git'

Example

  active_admin_import :validate => true do
    flash[:notice] = "#{@importer.result[:imported]} records were imported successfully" if @importer.result[:imported].to_i > 0
    if @importer.result[:failed].any?
      flash[:warning] = "#{@importer.result[:failed].count} records were not imported"
      invalid_item =  @importer.result[:failed][0]
      flash[:error] =  "#{invalid_item.name} errors: #{invalid_item.errors.full_messages.join(',')}"
    end
  end

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

released 2.1.1

from active_admin_import.

stonehz avatar stonehz commented on July 30, 2024

👍

from active_admin_import.

tdutreui avatar tdutreui commented on July 30, 2024

Hi @Fivell
I tried to use the code you provided on your comment, but it fails. There is a character escaping added everytime I call @importer.headers :

@importer.headers
=> {"[\"title\", \"title\"]"=>"[\"title\",_\"title\"]", "[\"description\", \"description\"]"=>"[\"description\",_\"description\"]", ...}

Note : it works if I do the same inside the after_batch_import proc

import.headers
=> {"title"=>"title", "description"=>"description",...

I'm using version 2.5.1

from active_admin_import.

Fivell avatar Fivell commented on July 30, 2024

@tdutreui feel free to create PR

from active_admin_import.

Nishan983 avatar Nishan983 commented on July 30, 2024

Hi @Fivell. I am a newbie to rails and active admin. I tried using the above code with slight modification to show error messages. But I am getting an error message for flash. Could you please help me?

error: undefined local variable or method for flash.

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.