Best way to load module/class from lib folder in Rails 3?

后端 未结 12 1905
别跟我提以往
别跟我提以往 2020-11-22 11:56

Since the latest Rails 3 release is not auto-loading modules and classes from lib anymore, what would be the best way to load them?

From github:

12条回答
  •  温柔的废话
    2020-11-22 12:26

    Spell the filename correctly.

    Seriously. I battled with a class for an hour because the class was Governance::ArchitectureBoard and the file was in lib/governance/architecture_baord.rb (transposed O and A in "board")

    Seems obvious in retrospect, but it was the devil tracking that down. If the class is not defined in the file that Rails expects it to be in based on munging the class name, it is simply not going to find it.

提交回复
热议问题