Rails /lib modules and

后端 未结 5 537
死守一世寂寞
死守一世寂寞 2020-11-27 09:43

I am writing a custom wrapper for open_flash_chart plugin. It\'s placed in /lib and load it as a module in ApplicationController.

5条回答
  •  情话喂你
    2020-11-27 10:02

    In Rails 3 /lib modules are not loaded automatically.

    This is because the line:

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

    inside config/application.rb is commented.

    You can try to uncomment this line or, (it worked even better for me), leave this commented (for future reference) and add this two lines:

    config.autoload_paths += %W(#{config.root}/lib)
    config.autoload_paths += Dir["#{config.root}/lib/**/"]
    

提交回复
热议问题