Stop Rails from unloading a module in development mode

前端 未结 1 762
南方客
南方客 2021-02-09 23:50

I have a module in my Rails app that lives in /lib

module MyModule
  mattr_accessor :the_variable

  class << self
    def setup
      yield this
    end
          


        
相关标签:
1条回答
  • 2021-02-09 23:59

    In your environment file before referencing MyModule, use require to load the file.

    require 'my_module'
    

    this bypasses the dynamic dependency loading mechanism.

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