Generate CSV file from rails
Posted
by Elliot
on Stack Overflow
See other posts from Stack Overflow
or by Elliot
Published on 2010-03-18T19:17:48Z
Indexed on
2010/03/18
19:21 UTC
Read the original article
Hit count: 408
ruby-on-rails
|csv
I've been reading similar questions, but many of the answers are outdated or not clear enough for me.
I'd like to be able to just do something like (in a controller action):
respond_to do |format|
format.html
format.csv
end
I know I'd then need a view such as action.csv.erb
So my questions are:
1) What do I need to configure in rails to allow this to happen in general.
2) How should I setup the CSV view to display some basic fields from a model?
© Stack Overflow or respective owner