Sha256: c1a5540a9fa6f310df582171b03aa6b8aca0ecec7268e435aaea9bac592a5426

Contents?: true

Size: 805 Bytes

Versions: 2

Compression:

Stored size: 805 Bytes

Contents

= CsvRails

CsvRails provides a simple way of download csv in Rails 3.

== Install

To use CsvRails simply add the line

    gem 'csv_rails'

to your Gemfile and then run

    bundle install

== Example

    class UsersController < ApplicationController
      def index
        @users = User.all

        respond_to do |format|
          format.html { @users = @users.all }
          format.json { render json: @users }
          format.csv{ render csv: @users, :fields => [:id, :name, :age], :encoding => 'SJIS' }
        end
      end


== Usage

If you want formatted created_at in the csv you should write like this

    class User < ActiveRecord::Base
      def created_at_as_csv
        created_at.strftime("%F %H:%M")
      end
    end
    
Copyright (c) 2012 yalab, released under the MIT license

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
csv_rails-0.4.1 README.rdoc
csv_rails-0.4.0 README.rdoc