我已經運行bundle exec rake db:migrate並有2個數據庫。我也在開發中使用SQLite。 我收到以下錯誤,當我去http://localhost:3000/auth/facebook:Onmiauth-Facebook不保存facebook_id給用戶表
You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[]
它指向這段代碼的應用程序/控制器/ sessions_controller.rb:12:'創建」 :
def create
auth_hash = request.env['omniauth.auth']
@authorization = Authorization.find_by_provider_and_uid(auth_hash["provider"], auth_hash["uid"])
if @authorization
render :text => "Welcome back #{@authorization.user.name}! You have already signed up."
else
######line 12-> user = User.new :name => auth_hash["user_info"]["name"], :email => auth_hash["user_info"]["email"]
user.authorizations.build :provider => auth_hash["provider"], :uid => auth_hash["uid"]
user.save
render :text => "Hi #{user.name}! You've signed up."
end
end
我認爲這意味着我的信息數組是空的,並縮小了我的理由,即數據沒有保存到我的數據庫中。
順便說一句,我在第6步以下http://net.tutsplus.com/tutorials/ruby/how-to-use-omniauth-to-authenticate-your-users/
你有沒有解決這個問題?我有完全相同的問題。 – John 2011-12-28 02:18:15