ruby-on-railsdeviserpx

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,


Solution

  • 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