fbgraph:未定义的方法`encode_json'for true:trueclass
-
23-10-2019 - |
题
我的代码:
def start
redirect_to client.authorization.authorize_url(:redirect_uri => callback_oauth_url,
:scope => "email,user_birthday,user_hometown,user_interests,user_location,user_notes,user_status,sms,publish_stream")
end
def callback
access_token = client.authorization.process_callback params[:code], :redirect_uri => callback_oauth_url
session[:access_token] = access_token
render :json => client.selection.me.info! # <-- HERE IS THE ERROR >.<
end
我去了 /oauth/start/
并成功签名并允许我的应用程序。之后,Facebook将我重定向回到我的应用程序,这给出了此错误:
oauthcontroller中的nomethoderror#回调
undefined method `encode_json' for true:TrueClass
我们都讨厌错误,也是我。我该如何解决?谢谢。
解决方案
这 info!
方法返回一个实例 FBGraph::Result
, ,你需要打电话 data
在上面,铁轨可以将其编码为JSON。以下代码对我有效:
render :json => client.selection.me.info!.data
不隶属于 StackOverflow