Plugins - to_csv
Add to favoritesto_csv
This plugin provides support for responding to the CSV format, as well as exporting a collection of ActiveRecord objects to CSV.
Installation
./script/plugin install -x http://svn.integralserver.com/plugins/to_csv
Usage
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
Copyright © 2006 Chris Abad released under the MIT license
http://blog.integralimpressions.com/articles/2006/09/01/tocsv-plugin
http://svn.integralserver.com/plugins/to_csv
Rails' (MIT)
Controllers

you have error in code.. fix line 35 delimeter => delimiter