I’m working in a new rails app and I created a little utility class in RAILS_ROOT/lib. I use this class in one of the controller with a require. In local this class is correctly loaded but when I deploy the app on heroku it crashes with:
LoadError (no such file to load — MyUtilityClass)
Any ideas?
UPDATE:
I found the problem. In my controller I did a ‘require “MyUtilityClas” ‘ and that was working fine locally. On heroku I needed to do a ‘require “/lib/my_utility_class.rb” ‘. Hmmm… I do not really understand why in fact…
you want
require 'my_file_to_require'assuming you’ve named your file properly.Require takes the filename, not the module/class name, so:
is wrong but
is correct, again assuming you’ve stuck to the normal ruby/rails file naming conventions.