crafterm/comma — pull request #41 by cschulte22 (2012-06-18 17:19:30+00:00)
Title: Custom columns

I ran into an issue where I need to be able to generate a CSV with custom columns defined by the user. I couldn't figure out any way to do this with the existing code - it looks like you always have to know the number of columns at "compile time".

I added some code so you can specify a block for 'custom_columns' which returns an array of 2-item arrays (where the first is used as the header and the last is used as the value). I wrote about it more in the README file along with an example:

https://github.com/cschulte22/comma/tree/custom_columns#dynamic-columns

Let me know if this looks good. I can merge it into the master branch and do another pull request for the Rails 3 code as well (I'm still using 2.3 right now so that's why I'm working off the rails2 branch).