简体   繁体   中英

How to access a variable in initializer file in Rails

I have Devise and Devise_RPX_Connectable (https://github.com/chrisdebruin/devise_rpx_connectable) working (users can login with their facebook account). I'm using

rails -v 2.3.5 devise --version 1.0.8 devise_rpx_connectable --version 0.1.3

My question is how do I access the advanced user information in my controllers? Specifically the ones listed below are in my devise.rb file in the initializers directory.

config.rpx_auto_create_account = true # false if you don't want to create users automaticaly. True by default. 
config.rpx_additional_user_data = [:verifiedEmail, :url, :providerName,:photo] # default [], get some extra profile info from RPXnow, default only a few fields are available in the rpx_user object (https://rpxnow.com/docs#profile_data) 
config.rpx_extended_user_data = true # false by default, extended data only available for Plus and Pro RPX users (https://rpxnow.com/docs#api_auth_info)

Thanks,

I checked out the Devise source and it looks like those are using Rails' mattr_accessor method which should expose them publicly on the Devise module. You should be able to access them like so:

Devise.rpx_auto_create_account # returns true 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM