What is the best way to read the Rails session secret? What is the best way to read the Rails session secret? ruby ruby

What is the best way to read the Rails session secret?


For Rails4

Rails.configuration.secret_tokenRails.configuration.secret_key_base

For Rails3

Rails.configuration.secret_token

But if for Rails2.x, like Don Parish mentioned

ActionController::Base.session_options[:secret]


Thanks, Jake.

Since the secret doesn't change based on the request or the action, this also works:

ActionController::Base.session_options_for(nil,nil)[:secret]


ActionController::Base.session_options_for(request,params[:action])[:secret]