Controller not recognizing installed Gem

199 Views Asked by At

Okay, I know this is a bit of a simple question, but I can't seem to get it to work. I have installed the SmarterCSV gem in my Rails 4 app and am trying to use it in my controller like so:

SmarterCSV.process("/files/csv_file.csv")

I can do this exact process in the rails console for this app, but I cannot seem to get it to work in my controller. Every time I just get the Rails Dead Screen saying uninitialized constant MyController::SmarterCSV. I have tried adding the line

require 'smarter_csv'

But that also breaks to the Rails Dead Screen with the error cannot load such file -- smarter_csv

Any help would be greatly appreciated, Im not entirely sure what I can do...

2

There are 2 best solutions below

2
bigsolom On

you can try require 'smarter_csv/smarter_csv' as this is the path of the file in the gem https://github.com/tilo/smarter_csv/blob/master/lib/smarter_csv/smarter_csv.rb

0
Ahmed Kamal On

Don't forget to restart your application after bundle install