Giter VIP home page Giter VIP logo

rails_admin_import's Introduction

Request for Contributors / Core Contributors

I apologize for my extreme lack of attention to this repository since it was created. I see that several users have forked this gem and applied updates. I'd be interested in giving access to this main repository for any interested in maintaining it and/or adding features. Please contact me if you are interested at steph at endpoint dot com.

Rails Admin Import functionality

Plugin functionality to add generic import to Rails Admin interface

Installation

  • First, add to Gemfile:

      gem "rails_admin_import"
    
  • Next, mount in your application by adding following line to your config/routes.rb:

      mount RailsAdminImport::Engine => '/rails_admin_import', :as => 'rails_admin_import'
    
  • If you are using cancan, add to ability.rb to specify which models can be imported:

      can :import, [User, Model1, Model2]
    
  • Define configuration in config/initializers/rails_admin_import.rb:

      RailsAdminImport.config do |config| 
        config.model User do
          excluded_fields do
            [:field1, :field2, :field3]
          end
    
          label :name
    
          extra_fields do
            [:field3, :field4, :field5]
          end
    
          import_only_if_all_records_valid do
            true
          end
    
          belongs_fields_mapping do
            {'belong_field_name' => 'actual_belong_field'}
          end
    
          # Display update existing record by update lookup fields
          allow_update_existing_record do
            true
          end
        end
      end
    
  • (Optional) Define instance methods to be hooked into the import process, if special/additional processing is required on the data:

      # some model
      def before_import_save(row, map)
        # Your custom special sauce          
      end
    
      def after_import_save(row, map)
        # Your custom special sauce          
      end
    
  • "import" action must be added inside config.actions block in main application RailsAdmin configuration: config/initializers/rails_admin.rb.

      config.actions do
        ...
        import
        ...
      end
    

    Refer to RailAdmin documentation on custom actions that must be present in this block.

  • TODO: Right now, import doesn't work for fields ending in s, because inflector fails in models ending in s singularly. Belongs_to and many mapping needs to be updated to use klasses instead of symbols

TODO

  • Testing

Copyright

Copyright (c) 2014 End Point & Steph Skardal. See LICENSE.txt for further details.

rails_admin_import's People

Contributors

chewi avatar crackcomm avatar sanchojaf avatar stephskardal avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

cooldoni

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.