Closed Tresor11 closed 4 years ago
Thank you for reporting that.
You shouldn't have to require csv-importer. Having the gem listed in the Gemfile should be sufficient.
I'm wondering if that could be related to Ruby 2.7 and / or Rails Zeitwerk?
Thank you for reporting that.
You shouldn't have to require csv-importer. Having the gem listed in the Gemfile should be sufficient.
I'm wondering if that could be related to Ruby 2.7 and / or Rails Zeitwerk?
Thank you for looking at this PR, as you mentioned the problem is likely to be related to those two. maybe we could mention in the readme that users with Ruby 2.7 might need to require csv-importer first
Edit
after a little troubleshooting, I realized that giving the class the same name as the file solves the issue.
ex: My file name was cars_importer.rb
and my class name was class CarImporter
by changing it to class CarsImporter
the
the issue was solved.
I'd like to know if that worth mentioning in the readme, if not this can be closed thanks
Oh, I just noticed your edit. Indeed, rails autoloading requires the class and file name to match. Thank you for the update!
I'm using the
csv-importer
with'rails', '~> 6.0.3'
andruby '2.7.1'
while creating an importer I ran into the following error.<class:MyImporter>': uninitialized constant MyImporter::CSVImporter (NameError)
I had to require thecsv-importer
before I could include it in my importer class. I thought it might be useful to mention that so In this PR I updated the usage section of the README