期待していなかったときは、nilのオブジェクトを持っている:OmniAuth/Railsの - あなたは私が私のRailsアプリケーションで次のエラーを取得していると私はデバッグやそれを修正について移動する方法が分からない、それ
NoMethodError in AuthenticationsController#create
を期待していないときは、オブジェクトがありません。 ActiveRecord :: Baseの インスタンスが必要になることがあります。 nilを評価しながら エラーが発生しました[]
Rails.root:。 /Users/phil/Sites/travlrapp.com アプリケーションのトレース|フレームワークトレース| 完全なトレース
アプリ/コントローラ/ authentications_controller.rb:15: に `」
を作成し、コントローラがこれです:
class AuthenticationsController < ApplicationController
def index
@authentications = current_user.authentications if current_user
end
def create
omniauth = request.env["omniauth.auth"]
unless omniauth
redirect_to authentications_url
flash[:notice] = "Could not authenticate via #{params['provider']}."
end
authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
if authentication
flash[:notice] = "Signed in successfully."
sign_in_and_redirect(:user, authentication.user)
elsif current_user
current_user.authentications.create!(:provider => omniauth['provider'], :uid => omniauth['uid'], :token => omniauth['credentials']['token'], :secret => omniauth['credentials']['secret'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
else
user = User.new
user.apply_omniauth(omniauth)
if user.save
flash[:notice] = "Signed in successfully."
sign_in_and_redirect(:user, user)
else
session[:omniauth] = omniauth.except('extra')
redirect_to new_user_registration_url
end
end
end
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
flash[:notice] = "Successfully destroyed authentication."
redirect_to authentications_url
end
end
OmniAuthが正常に動作するために使用され、その後、私はそれをマッシュflickrをサポートしていたptiltonによってフォークにスワップしようとしています。私はgemfileにgit =>を設定して再インストールしようとしましたが、私は正しくこれをやりました。
すべてのomniauthファイルとoa-foo gemファイルを手動で削除し、最初に現在の安定版(0.1.6)とgitマスターコピーをインストールしましたが、すべてのエラーは同じです。
本当にここで紛失していますが、誰も私が知っていることは問題が何であるかを知っていません。
お返事ありがとうございます。うん、ルートは適切な場所にあります:http://d.pr/SoEj –