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

前端 未结 4 1774
名媛妹妹
名媛妹妹 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:05

    Rename the initializer to 01_name.rb, that will force it to load alphabetically previously.

    Edit

    To quote the official Rails Guide for configuration (thanks zetetic for the tip):

    If you have any ordering dependency in your initializers, you can control the load order by naming. For example, 01_critical.rb will be loaded before 02_normal.rb.

提交回复
热议问题