Skip to content

invzn/tabularasa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This simple gem gives you the ability to convert an array of activerecords, hashes, and/or arrays to tabular data.

@users = User.all

#
# defaults are export headers and all fields
#

@users.to_csv
@users.to_csv(:only => [:last_name, :role]) # This will also set the order
@users.to_csv(:delimiter => ';') # This will set the delimiter between values in a row
@users.to_csv(:headers => ["Last Name", "Role"])
@users.to_csv(:except => [:last_name, :role])
class UserController < ApplicationController
  def index
    @users = User.all

    respond_to do |format|
      format.html
      format.xml { render :xml => @users }
      format.csv { send_data @users.to_csv }
    end
  end
end
ruby >= 1.9
  * activerecord
ruby < 1.9
  * activerecord
  * fastercsv
gem install tabularasa
  • Chris Rosario

Copyright © 2011 Chris Rosario, released under the MIT license

About

Gives the ability to convert homogeneous activerecord and/or hash objects into csv.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages