如果我有这样的配置文件
# config/environments/integration.rb
config.action_controller.session = {
:domain => ".example.com"
}
如何从我的应用程序 Controller 中获取值,例如:
# app/controller/application_controller
class ApplicationController < Mcc::CoreSupport::FrontendController
def some_method
value = xxx
end
end
最佳答案
在 Ruby on Rails 3 及以上版本中,您可以通过 Rails.application.config
访问配置
在更新的版本中,您可以改用 Rails.configuration
。例如:Rails.configuration.time_zone
。
在 official manual on configuration 中查看更多信息
关于ruby-on-rails - 如何从应用程序 Controller 中读取 ruby on rails 配置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1916193/