I need export data as CSV in rails appl. I found this plugin: https://github.com/crafterm/comma. Do you know about some better solution?
If using Ruby 1.9.x, then use CSV rather than FasterCSV and stick with the default delimiters.
Controller:
respond_to do |format|   ...              format.csv { render :layout => false } end   show.csv.erb:
<%= this_is_your_view_helper_method.html_safe %>   controller_helper.rb:
require 'csv'  def this_is_your_view_helper_method   CSV.generate do |csv|      Product.find(:all).each do |product|       csv << ... add stuff here ...     end   end end 
                        Checkout this Stack Overflow answer for using CSV in Ruby 1.9.x (which, as Fletch noted, includes FasterCSV but with slightly different syntax).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With