In my Rails app, what would be the way to access a Devise config variable directly from a view?
I want to show config.allow_unconfirmed_access_for
from Devise's :confirmable
module. This variable is set in devise.rb
initializer:
Devise.setup do
config.allow_unconfirmed_access_for = 3.days
end
Thanks!
The configurations on devise.rb
file are replicated on your Devise model, so if your Devise resource is User
, you should be able to access it through User.allow_unconfirmed_access_for
.
So, create an instance variable on your controller and assign this value to it, and then you'll be able to show it on your view.
The accepted answer is no longer correct. For more recent Devise versions, the config options are tacked on to the main Devise
module, e.g. Devise.allow_unconfirmed_access_for
.
This answers a similar question:
OmniAuth config is stored in an omniauths_config object within a nested stragety object
Devise.omniauth_configs
returns:
{:facebook=>
#<Devise::OmniAuth::Config:0x007fa6db95aa68
....
then access via symbol:
Devise.omniauth_configs[:facebook].strategy
{"setup"=>true,
"skip_info"=>false,
"client_id"=>nil,
"client_secret"=>nil,
"client_options"=>{"site"=>"https://graph.facebook.com", "authorize_url"=>"https://www.facebook.com/dialog/oauth", "token_url"=>"/oauth/access_token"},
"authorize_params"=>{},
"authorize_options"=>[:scope, :display, :auth_type],
"token_params"=>{"parse"=>:query},
"token_options"=>[],
"auth_token_params"=>{},
"provider_ignores_state"=>false,
"access_token_options"=>{"header_format"=>"OAuth %s", "param_name"=>"access_token"},
"scope"=>"email,public_profile,publish_actions",
"info_fields"=>"email, first_name, last_name",
"name"=>"facebook"}