Reputation: 1901
I have a lib/redirect_follower.rb
file
Where I use the file, I include it with require 'RedirectFollower'
But rails is playing hard ball with this error:
no such file to load -- RedirectFollower
Any clues? Been banging my head over this for hours. Have tried auto loading all libs using application.rb but that didn't work either.
Upvotes: 4
Views: 545
Reputation: 11198
In config/application.rb:
add this:
config.autoload_paths << "#{config.root}/lib"
With this setting, your modules (i.e. files under lib/) will be automatically required so you don't have to require them anywhere (actually, you should never require them because that would have an negative effect on un/loading files by Rails).
Upvotes: 2
Reputation: 239541
require
is for including a file, not a class.
You need to require "redirect_follower"
, ie, the actual filename, not the class name. You may also need to add lib
to your include path, or require "lib/redirect_follower"
.
Upvotes: 3