fbgraph:未定义的方法“encode_json”对于真:TrueClass
我的代码:
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#callback 中出现 NoMethodError
true:TrueClass 的未定义方法 `encode_json'
我们都讨厌错误,我也是。我该如何解决这个问题?谢谢。
My code:
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
I went to /oauth/start/
and successfully signed in and allowed my app. Afterwards, Facebook redirected me back to my app, which gave this error:
NoMethodError in OauthController#callback
undefined method `encode_json' for true:TrueClass
We all hate errors and so do I. How can I fix this? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
info!
方法返回一个FBGraph::Result
实例,您需要对其调用data
以便 Rails 可以将其编码为 JSON。以下代码对我来说效果很好:
The
info!
method returns an instance ofFBGraph::Result
, you need to calldata
on it so that Rails can encode it into JSON.The following code works fine for me :