1

我的代码:

  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

undefined method `encode_json' for true:TrueClass

我们都讨厌错误,我也是。我该如何解决这个问题?谢谢。

4

1 回答 1

2

info!方法返回一个 的实例FBGraph::Result,您需要调用data它以便 Rails 可以将其编码为 JSON。以下代码对我来说很好:

render :json => client.selection.me.info!.data
于 2011-02-17T19:29:59.303 回答