Sohan's Blog

Living the Developer's Life

Released Streamy_csv Gem

Following the previous post, I decided to spin off a little ruby gem for you folks. Get streamy_csv, and write only your application code while it’ll do the boilerplate work for you.

In a nutshell, with this gem in your application, all you need to do is this:

1
2
3
4
5
6
7
8
9
10
11
12
Class ExportsController

  def index

    stream_csv('data.csv', MyModel.header_row) do |rows|
      MyModel.find_each do |my_model|
        rows << my_model.to_csv_row
      end
    end

  end
end

Find more at https://github.com/smsohan/streamy_csv

Comments