29

If i have a configuration file like this

# config/environments/integration.rb
config.action_controller.session = {
  :domain => ".example.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

2 Answers 2

70

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

Sign up to request clarification or add additional context in comments.

1 Comment

Works on Rails 5.1.1
8

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]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.