1 Star 0 Fork 0

算法与编程之美/rails_admin_import

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
gschen01-gschen01 gschen01 ss 3abdbb8 11年前
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

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
        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.

Copyright 2012 YOURNAME Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

Rails Admin Import functionality 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Ruby
1
https://gitee.com/algo_coding/rails_admin_import.git
git@gitee.com:algo_coding/rails_admin_import.git
algo_coding
rails_admin_import
rails_admin_import
master

搜索帮助