Code Monkey home page Code Monkey logo

active_admin_import's Introduction

ActiveAdminImport

The most fastest and efficient CSV import for Active Admin (based on activerecord-import gem) with support of validations and bulk inserts

#Links https://github.com/gregbell/active_admin

https://github.com/zdennis/activerecord-import

#Options

# +back+:: resource action to redirect after processing
# +col_sep+:: column separator used for CSV parsing
# +validate+:: true|false, means perfoem validations or not
# +batch_size+:: integer value of max  record count inserted by 1 query/transaction
# +before_import+:: proc for before import action, hook called with  importer object
# +after_import+:: proc for after import action, hook called with  importer object
# +before_batch_import+:: proc for before each batch action, called with  importer object
# +after_batch_import+:: proc for after each batch action, called with  importer object
# +fetch_extra_options_from_params+:: params  available in callbacks ( importer.extra_options proprty hash ) 
# +on_duplicate_key_update+:: an Array or Hash, tells activerecord-import to use MySQL's ON DUPLICATE KEY UPDATE ability.
# +timestamps+::  true|false, tells activerecord-import to not add timestamps (if false) even if record timestamps is disabled in ActiveRecord::Base
# +ignore+::  true|false, tells activerecord-import toto use MySQL's INSERT IGNORE ability
# +params_keys+:: params values available in callbacks
# +template+:: custom template rendering
# +template_object+:: object passing to view
# +locals+:: local variables for template
# +resource_class+:: resource class name
# +resource_label+:: resource label value
# +headers_rewrites+:: hash with key (csv header) - value (db column name) rows mapping

Default options values

:back => :import,
:col_sep => ',',
:template => "admin/import",
:template_object => ActiveAdminImport::Model.new,
:fetch_extra_options_from_params => [],
:resource_class => nil,
:resource_label => nil,

#Example

ActiveAdmin.register Post  do
   active_admin_import :validate => false,
                        :col_sep => ',',
                        :back => :index ,
                        :before_import => proc{|importer|  Model.delete_all},
                        :batch_size => 1000


end

#Source Doc http://rubydoc.info/gems/active_admin_import/2.0.0/

active_admin_import's People

Contributors

fivell avatar

Watchers

 avatar

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.