开发者

How to read ruby on rails config values from within the application controller

开发者 https://www.devze.com 2022-12-14 17:05 出处:网络
If i have a configuration file like this # config/environments/integration.rb config.action_controller.session = {

If i have a configuration file like this

# config/environments/integration.rb
config.action_controller.session = {
  :domain => ".exa开发者_JAVA百科mple.com"
}

How do I get the value from within my application controller, e.g:

# app/controller/application_controller
class ApplicationController < Mcc::CoreSupport::FrontendController
  def some_method
    value = xxx
  end
end


In Ruby on Rails 3 and above, you can access the config through Rails.application.config


In more recent versions, you can use Rails.configuration instead. For example: Rails.configuration.time_zone. See more in the official manual on configuration


The class method ActionController::Base.session_options returns a hash of the configuration options for the session.

So in your case you want ActionController::Base.session_options[:domain]

0

精彩评论

暂无评论...
验证码 换一张
取 消