Rails アプリケーションで次のエラーが発生しましたが、デバッグまたは修正する方法がわかりません。
AuthenticationsController#create の NoMethodError
予期していなかったのに nil オブジェクトがあります! ActiveRecord::Base のインスタンスを期待していたかもしれません。nil の評価中にエラーが発生しました。[]
Rails.root: /Users/phil/Sites/travlrapp.com アプリケーション トレース | フレームワーク トレース | 完全なトレース
app/controllers/authentications_controller.rb:15:in `create'
コントローラーはこれです:
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 をサポートする pchilton によるフォークにスワップしようとして、OmniAuth をマッシュアップしました。これを行うには、gemfile で :git => を設定して再インストールを試みましたが、正しく行ったことがあるとは確信していません。
すべての omniauth および oa-foo gem ファイルを手動で削除し、最初に現在の安定版 (0.1.6) と git マスター コピーをインストールしましたが、すべてのエラーは同じです。
ここで本当に途方に暮れています。私が知っている誰も問題が何であるかを知りません。