Rails - Unable to use gem in controller

262 Views Asked by At

I am attempting to use the Roo gem to parse a spreadsheet file in my Rails controller. I have added the appropriate line to my Gemfile and ran the bundle command. Here is the line in my controller where everything breaks:

xlsx = Roo::Spreadsheet.open(filepath)

I receive an error: uninitialized constant MyController::Roo. I then added the following line to the top of my controller file (as specified in the Roo readme):

require 'roo'

Now I get a different error: Error during failsafe response: cannot load such file -- roo.

What am I doing wrong?

1

There are 1 best solutions below

0
On BEST ANSWER

Did you bundle and restart your server?

Adding gems, modifying app/config files or app/lib files require a server restart :)