我下面這個教程Omniauth:http://railscasts.com/episodes/235-omniauth-part-1?view=asciicastRuby on Rails的沒有這樣的列:authentication.provider:Omniauth
我不斷收到此錯誤:
no such column: 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場。我也嘗試過每個地方(認證:auth)和哪裏(auth:auth) ,沒有運氣。
任何想法,將不勝感激。
UPDATE
authentication.rb(模型)
class Authentication < ActiveRecord::Base
attr_accessible :create, :destroy, :index, :provider, :uid, :user_id
belongs_to :user
end
更新2
基本上,我試圖適應本教程的軌道3.2。
本教程中的原始行被註釋掉。
更新3 這是錯誤的整個第一行:
SQLite3::SQLException: no such column: authentication.provider: SELECT "users".* FROM "users" WHERE "authentication"."provider" = 'facebook' AND "authentication"."uid" = '2222222' AND "authentication"."info" = '--- !ruby/hash:OmniAuth::AuthHash::InfoHash
不想成爲負擔......但是,時鐘的滴答作響真的,我的屁股就行了,我即將徹底瘋狂試圖找出這一點。如果你能告訴我爲什麼供應商沒有被接受,我相信我能弄清楚其餘的。
貴'Authentication'模型具有'provider'屬性?請向我們展示您的'Authentication'模型的註釋。 – vee
如果您向我們保證模型'Authentication'具有'provider'屬性,請發佈您的錯誤回溯。 – vee
更新了我的身份驗證模型。 –