I’m having really odd behavior with Rails, and I can’t seem to figure out the problem. When I do require inside of a file in config/initializers nothing gets required…at all, here is an example:
From: /home/jordon/development/test1/config/initializers/test1.rb @ line 6:
1: Dir[Test1::Application.config.root + '/lib/test1/**/*.rb'].each do |file|
2: # Test1::Patches::Redirecting
3: require file
4: end
5:
* 6: binding.pry
[1] pry(main)> Test1::Patches
^> NameError: uninitialized constant Test1::Patches
^> From (pry):1:in `<top (required)>'
[2] # The required file is from lib/test1.
[3] pry(main)> require 'rails/actionpack/lib/action_controller/metal/redirecting'
^> Return: true
Can anyone explain what is happening? Is there some kind of anti-require faerie built into Rails? No seriously, all joking aside can anyone seriously explain why Rails is not actually allowing my files to be required and how can I convince it to require my files so that I can attempt to extend redirect_to with wrappers.
Try to add
In your environment.rb, and restart your server.