# render_csv [![Build Status](https://travis-ci.org/beerlington/render_csv.png?branch=master)](https://travis-ci.org/beerlington/render_csv) [![Gem Version](https://badge.fury.io/rb/render_csv.png)](http://badge.fury.io/rb/render_csv) [![Code Climate](https://codeclimate.com/github/beerlington/render_csv.png)](https://codeclimate.com/github/beerlington/render_csv) [![Dependency Status](https://gemnasium.com/beerlington/render_csv.png)](https://gemnasium.com/beerlington/render_csv) Rails CSV renderer for ActiveRecord collections ## Rails & Ruby Versions Supported *Rails:* 3.0.x - 4.0.x *Ruby:* 1.9.3, 2.0.0 and 2.1.0 ## Installation The gem is hosted at [rubygems.org](https://rubygems.org/gems/render_csv) ## What is it? The CSV renderer allows you to render any collection as CSV data. ```ruby class LocationsController < ApplicationController def index @locations = Location.all respond_to do |format| format.csv { render csv: @locations } end end end ``` Will render a CSV file similar to:
name | address | city | state | zip | created_at | updated_at |
---|---|---|---|---|---|---|
Pete's House | 555 House Ln | Burlington | VT | 05401 | 2011-07-26 03:12:44 UTC | 2011-07-26 03:12:44 UTC |
Sebastians's House | 123 Pup St | Burlington | VT | 05401 | 2011-07-26 03:30:44 UTC | 2011-07-26 03:30:44 UTC |
Someone Else | 999 Herp Derp | Burlington | VT | 05401 | 2011-07-26 03:30:44 UTC | 2011-07-26 03:30:44 UTC |