Rails 3 autoload

后端 未结 4 1681
面向向阳花
面向向阳花 2020-12-01 09:45

I have a class ConstData:

class ConstData

  US_CITIES = [\'miami\', \'new york\']

  EUROPERN_CITIES = [\'madrid\', \'london\']

end

Its s

4条回答
  •  清歌不尽
    2020-12-01 10:14

    The post @daniel refers to is from 2008. Rails has changed since then.
    In fact, quite recently. Rails3 doesn't load the lib/ directory automatically.

    You can reactivate it quite easily though. Open config/application.rb And add, in the config (in the Application class) the followin :

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

    Then your lib/ dir will be autoloaded.

提交回复
热议问题