Rails unable to autoload constant from file despite being defined in that file

前端 未结 3 1739
傲寒
傲寒 2021-02-18 23:42

This is a tricky one to explain. I have a module in another module namespace like so:

# app/models/points/calculator.rb
module Points
  module Calculator
    de         


        
3条回答
  •  臣服心动
    2021-02-19 00:19

    If someone is having this issue in rails 6 which has zeitwerk autoloader,

    Change ruby constant lookup back to classic in your application.rb

    # config/application.rb
    #...
    config.autoloader = :classic
    #...
    

    Read more details here Rails Official Guides

提交回复
热议问题