我在Devise上使用Facebook Omniauth使用Rails 5应用程序,我希望将用户的{_ 1}}等public_profile信息提取到我的first_name, last_name, age_range, link, gender, locale, verified, user_location, and user_status
表中。现在,它只在使用默认的Devise设置时收到电子邮件: -
Users
我尝试编辑这些文件以获取详细信息,但它不起作用: -
# user.rb
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.uid).first_or_create do |user|
user.email = auth.info.email
user.password = Devise.friendly_token[0,20]
user.username = auth.info.name
user.photo = auth.info.image
user.skip_confirmation!
user.save
# devise.rb
config.omniauth :facebook, '..', '..', image_size: 'large'
我不知道如何正确地写上述内容以使其发挥作用。我有权获得# devise.rb
config.omniauth :facebook, '..', '..', image_size: 'large', scope: 'email, public_profile, user_location, user_status', info_fields: 'first_name, last_name, gender, age_range, etc.'
# user.rb
user.first_name = auth.extra.raw_info.first_name
user.last_name = auth.extra.raw_info.last_name
user.age_range = auth.extra.raw_info.age_range
user.gender = auth.extra.raw_info.gender
user.address = auth.info.user_location
user.status = auth.info.user_status
和user_location