Rails3 not reloading code in lib while in development mode

后端 未结 4 1004
暖寄归人
暖寄归人 2020-12-13 07:35

THE SITUATION:

  1. I have code in lib/foo/bar.rb with a simple method defined as such:

    module Foo
      class Bar
                 
    
    
            
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-13 08:27

    Autoloading code from the lib folder was intentionally disabled in rails3, see this ticket for more details.

    The workaround suggested by Samuel is a great start, however I found that certain environments still had difficulty finding the libraries in a testing environment (say being invoked from a cucumber scenario), and that including the root path, as suggested within the ticket and hinted by the original comment in application.rb was a more robust approach:

    config.autoload_paths += %W(#{config.root}/lib)
    

提交回复
热议问题