fbgraph: undefined method `encode_json' for true:TrueClass
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.
The info!
method returns an instance of FBGraph::Result
, you need to call data
on it so that Rails can encode it into JSON.
The following code works fine for me :
render :json => client.selection.me.info!.data
精彩评论