Auto-loading lib files in Rails 4

前端 未结 4 1691
陌清茗
陌清茗 2020-11-22 16:20

I use the following line in an initializer to autoload code in my /lib directory during development:

config/initializers/custom.rb:

4条回答
  •  太阳男子
    2020-11-22 16:23

    Though this does not directly answer the question, but I think it is a good alternative to avoid the question altogether.

    To avoid all the autoload_paths or eager_load_paths hassle, create a "lib" or a "misc" directory under "app" directory. Place codes as you would normally do in there, and Rails will load files just like how it will load (and reload) model files.

提交回复
热议问题