Skip to content

A Ruby on Rails Engine plugin that makes it easy to import CSV files, complete with error reporting and customization.

License

Notifications You must be signed in to change notification settings

jarrett/csv_import

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CsvImport

This Rails plugin provides a controller method called each_csv_row and an accompanying helper called csv_form.

By default, when each_csv_row is called, any exceptions raised in the block will be rescued. The rows that triggered the exceptions will then be displayed in a table as part of the output from csv_form.

You can turn off rescuing by calling each_csv_row(false).

Big thanks to Doorkeeper for their work updating this plugin to Rails 3.

Compatibility

  • Ruby 1.9
  • Rails 3

Usage

# app/controllers/members_controller.rb

class MembersController < ActionController::Base
  include CsvImport

  def create
    each_csv_row do |row|
      Member.create!(row)
    end
  end
end

# app/views/members/index.html.erb

<h1>Import Members</h1>

<%= csv_form members_path do %>

  <!-- whatever you put in the optional
  block will appear at the end of the form -->
<% end %>

About

A Ruby on Rails Engine plugin that makes it easy to import CSV files, complete with error reporting and customization.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages