I want to create a module in /lib folder & access that form my controllers. There are several solutions available in different websites, but modules are not loading.
Asked
Active
Viewed 634 times
0
Philidor
- 40,933
- 9
- 84
- 94
-
possible duplicate of [Auto-loading lib files in Rails 4](http://stackoverflow.com/questions/19098663/auto-loading-lib-files-in-rails-4) – Eyeslandic Jul 28 '14 at 13:31
1 Answers
1
You need to add:
config.autoload_paths += %W(#{config.root}/lib)
to your config/application.rb
And then:
require 'file_name'
in your controller. That works for me (Rails 4).
Grych
- 2,781
- 11
- 21