Renders CSV files as view templates
Ruby JavaScript
Latest commit 870a63a Mar 29, 2012 @rtsinani Update README.md
Permalink
Failed to load latest commit information.
lib improve template example Mar 23, 2012
test improve template example Mar 23, 2012
.gitignore first commit Mar 22, 2012
Gemfile first commit Mar 22, 2012
Gemfile.lock first commit Mar 22, 2012
MIT-LICENSE first commit Mar 22, 2012
README.md Update README.md Mar 29, 2012
Rakefile first commit Mar 22, 2012
blue_csv.gemspec update gemspec Mar 23, 2012

README.md

Write CSV files as if they were normal view templates and they will be downloaded as attachments.

Installation

  • Add the following to your app's Gemfile
gem 'blue-csv'
  • Or as a standalone gem by running on your shell:
gem install blue-csv

Usage

The plugin exposes the object csv in your view templates, so you can write in your index.csv.blue:

csv << ["Title", "Author"]

@books.each do |book|
  csv << [book.title, book.author]
end

Your controller code would look like this:

def index
  @books = Book.all
  respond_to do |format|
    format.html
    format.csv { render :csv => 'export' }
  end
end

Copyright © 2012 Artan Sinani