ActsAsExportable

Rails 2.3 plugin that exports ActiveRecord table data into a csv.

Important:

Rails 2.3 only
Requires the FasterCsv gem

Install

script/plugin install git://github.com/rossnelson/acts_as_exportable.git

Example

To get started, just specify an ActiveRecord class as acts_as_exportable
This will add all the Object's attributes to the CSV

class Contact < ActiveRecord::Base
  acts_as_exportable
end

You can also specify the attributes to be included

class Contact < ActiveRecord::Base
  acts_as_exportable :name, :email, :comment
end

At this point the class will be given the "build_csv" class method.

Contact.build_csv

As a convenience a view helper has also been provided.

link_to_export("Link Text", "ClassName", :html_options => {})

This will return a link for downloading the CSV

Copyright (c) 2011 Ross Nelson, released under the MIT license