views:

117

answers:

2

If i have a configuration file like this

# config/environments/integration.rb
config.action_controller.session = {
  :domain => ".example.com"
}

How do Ii 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
+3  A: 

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]

zetetic
A: 

You can't pull the config object directly, rails throws it away ofter initialization.

You need to either:

  1. store a reference to the config object in your initializer block
  2. find another way to access the variable

zetetic gave a good solution using (2) that should work for you

klochner