Rails doesn't load my module from lib

后端 未结 1 1072
耶瑟儿~
耶瑟儿~ 2021-01-14 04:47

I have a bunch of custom classes in my Rails 3.2 app in lib folder: i.e. extending ActiveRecord, etc. It all works fine.

However I\'m trying to add a couple of custo

1条回答
  •  醉梦人生
    2021-01-14 05:36

    Your patch is never going to be loaded because autoload is only invoked when Rails can't find a constant. Since the FileUtils constant already exists, the autoloader is never called, and your file is never loaded.

    Simply require it from an initializer.

    require File.join(Rails.root, "lib/file_utils.rb")
    

    0 讨论(0)
提交回复
热议问题