Agile Web Development

Build it. Launch it. Love it.

convertible to csv

It is very straight forward to use:

In your model declaration:

class Customer < ActiveRecord::Base
  acts_as_convertible_to_csv :header => true, 
                             :fields => %w(id firstname lastname email_address)
end

Getting the csv data from a collection of records:

Customer.find(:all).to_csv

You can pass a block:

Customer.find(:all).to_csv do |line|
  # do something with each line
end

You can also convert individual records to csv:

Customer.find(:first).to_csv

Vitals

Home http://rubygreenblue.com/project/convertible_to_csv
Repository svn://rubygreenblue.com/rubygreenblue_opensource/convertible_to_csv/trunk
License Rails' (MIT)
Rating (9 votes)
Owner Keith Rowell
Created 13 September 2006

Comments

Add a comment