How do I change the load order of initializers in Rails 3?

前端 未结 4 1788
名媛妹妹
名媛妹妹 2020-12-24 10:43

I have an initializer that loads configuration settings from a yaml file. I need to use these settings in other initializers. The settings are not being seen by the initiali

4条回答
  •  长情又很酷
    2020-12-24 11:07

    Even though the guide recommends prepending the initializer filenames with numbers, that does seem ugly. Another way is to utilize the provided initialization hooks. See http://guides.rubyonrails.org/configuring.html#initialization-events

    E.g.

    # application.rb
    
    module YourApp
      class Application < Rails::Application
        config.before_initialize do
         # initialization code goes here
        end
      end
    end
    

提交回复
热议问题