我安装了宝石koala
和omniauth
。
在我的user
模型中
class User < ActiveRecord::Base
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.image = auth.info.image
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.save!
end
end
def facebook
@facebook ||= Koala::Facebook::API.new(oauth_token)
end
end
我获得了facebook的许可,但我仍然无法获得关系状态?
答案 0 :(得分:2)
试试这个
@facebook.get_object('me',:fields=>"name,gender,relationship_status")