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
You probably know that you can configure Rails in config/application. rb and config/environments/development. rb etc. But you can also leverage that for configuring your own custom settings for your application.
In general, the work of configuring Rails means configuring the components of Rails, as well as configuring Rails itself. The configuration file config/application. rb and environment-specific configuration files (such as config/environments/production.
The Rails controller is the logical center of your application. It coordinates the interaction between the user, the views, and the model. The controller is also a home to a number of important ancillary services. It is responsible for routing external requests to internal actions.
An initializer is any file of ruby code stored under /config/initializers in your application. You can use initializers to hold configuration settings that should be made after all of the frameworks and plugins are loaded.
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]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With