加载 YAML 应用程序配置文件的最佳位置在哪里?
我已经为 Rails 3.1 应用程序设置了应用程序配置,如 Ryan Bates 此处所述。
问题是我想使用环境文件中的配置作为 ActionMailer 的用户名/密码,但 Ryan 建议从初始值设定项加载配置,并且它们似乎包含在environment.rb 之后。加载配置文件的最佳位置在哪里,以便整个 Rails 应用程序可以访问它?
谢谢
I have setup my application configuration for my rails 3.1 application as described here by Ryan Bates.
Problem is I want to use the config in my environment file for username/password for ActionMailer, but Ryan suggests loading the config from an initializer, and they seem to get included after environment.rb. Where is the best place to load the configuration file so it can be accessed by the whole rails application?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这种情况下,该代码应该作为预初始化程序进入。 行之前
从 Rails 3 开始,所有预初始化代码都需要位于 application.rb 的顶部附近,就在
require 'rails/all'
application.rb:In that case, this code should go in as a pre-initializer. As of Rails 3, all pre-initialization code needs to go near the top of application.rb, just before the line
require 'rails/all'
application.rb: