When and where do I require files in a rails application?

前端 未结 5 1619
半阙折子戏
半阙折子戏 2021-02-03 22:00

Let\'s say I have I have the following file in my lib directory of my rails application:

#lib/proxy.rb
module SomeService
  class ServiceProxy
    def do_somethi         


        
5条回答
  •  孤街浪徒
    2021-02-03 22:35

    Rails will auto add /lib /vendor /app this dir into autoload path. When you need some constants in it, you need to require the specific file. And you don't need to require it the second time, because it would be useless.

提交回复
热议问题