我在 Omniauth 上关注本教程:http: //railscasts.com/episodes/235-omniauth-part-1?view=asciicast
我不断收到此错误:
没有这样的列:authentication.provider:
现在我想知道的主要事情是为什么“提供者”不被接受。它存在于类中……身份验证数据库存在……那为什么说它不存在呢?
这是我的身份验证控制器:
class AuthenticationsController < InheritedResources::Base
def index
@authentications = current_user.authentications if current_user
end
def create
@user = User.where(authentication: auth).first_or_create(:provider => auth['provider'], :uid => auth['uid'])
self.current_user = @user
# auth = request.env["omniauth.auth"] current_user.authentications.create(:provider => auth['provider'], :uid => auth['uid'])
flash[:notice] = "Authentication successful."
redirect_to authentications_url
end
def auth
request.env['omniauth.auth']
end
def destroy
@authentication = current_user.authentications.find(params[:id])
@authentication.destroy
flash[:notice] = "Successfully destroyed authentication."
redirect_to authentications_url
end
end
我可以向您保证,我有一个称为身份验证的模型,并且该模型具有提供程序和 uid 字段。我也试过 where(authentications: auth) 和 where(auth: auth) 都没有运气。
任何想法,将不胜感激。
更新
authentication.rb (模型)
class Authentication < ActiveRecord::Base
attr_accessible :create, :destroy, :index, :provider, :uid, :user_id
belongs_to :user
end
更新 2
我基本上是在尝试使本教程适应 rails 3.2。
教程中的原始行已在上面注释掉。
更新 3 这是整个第一行错误:
SQLite3::SQLException: 没有这样的列: authentication.provider: SELECT "users".* FROM "users" WHERE "authentication"."provider" = 'facebook' AND "authentication"."uid" = '2222222' AND "authentication "."info" = '--- !ruby/hash:OmniAuth::AuthHash::InfoHash
讨厌成为负担......但时间真的很紧迫,我的屁股已经上线了,我要完全疯了,试图弄清楚这一点。如果您能告诉我为什么不接受提供者,我相信我可以弄清楚其余的。