Natalia Natalia - 1 month ago 5
Ruby Question

Where is the CSV gem in Rails?

I’m using Rails 4.2 with Ruby 2.3.0. I want to use the CSV parsing library, which according to the documentation is part of the core Ruby distribution — https://ruby-doc.org/stdlib-2.0.0/libdoc/csv/rdoc/CSV.html . However, when I put this on my page

csv = CSV.parse(text_content, :headers => true)


it results in this error

Error during processing: uninitialized constant CsvToActivityConverterService::CSV


Do I need another gem to include the CSV library in my Rails project?

Answer

You need to require 'csv' to use it!