Plugin details

This plugin provides support for responding to the CSV format, as well as exporting a collection of ActiveRecord objects to CSV.

Websitehttp://blog.integralimpressions.com/articles/2006/09/01/tocsv-plugin Repositoryhttp://svn.integralserver.com/plugins/to_csv Author Chris Abad Tags csv LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install http://svn.integralserver.com/plugins/to_csv

You can simply take a collection of ActiveRecord objects and apply the to_csv method to them:

@users = User.find(:all)
@users.to_csv


For a more RESTful way of exporting a CSV, do something like this in your controller:

respond_to do |wants|
  wants.csv do
    render :text => @users.to_csv
    response.headers['Content-Type'] = 'text/csv; charset=iso-8859-1; header=present'
    response.headers['Content-Disposition'] = "attachment; filename=users_#{Time.now.strftime("%m-%d-%Y")}.csv"
  end
end

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 year ago