Created
December 12, 2011 22:44
-
-
Save daveworth/1469495 to your computer and use it in GitHub Desktop.
Now with more headers...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class OurModel < ActiveRecord::Base | |
| # ... snip ... | |
| def generate_csv_template(account_id) | |
| headers = <<HEADERS | |
| first_name,last_name,birth_date,pet_name | |
| HEADERS | |
| headers += CustomModel.find_all_by_account_id(account_id). | |
| map(&:name).join(",") | |
| CSV.generate { |csv| csv << headers.split(/\s*,\s*/)} | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment