Ruby on rails ActiveRecord::语句在SessionController#create/SQLite3::SQLException中无效:没有这样的列:users.provider
我试图在我的ap上创建facebook登录,当单击“使用facebook登录”时,我在运行时遇到此错误Ruby on rails ActiveRecord::语句在SessionController#create/SQLite3::SQLException中无效:没有这样的列:users.provider,ruby-on-rails,ruby,facebook,activerecord,sqlite,Ruby On Rails,Ruby,Facebook,Activerecord,Sqlite,我试图在我的ap上创建facebook登录,当单击“使用facebook登录”时,我在运行时遇到此错误 ActiveRecord::StatementInvalid in SessionsController#create SQLite3::SQLException: no such column: users.provider: SELECT "users".* FROM "users" WHERE "users"."provider" = 'facebook' AND "users"."ui
ActiveRecord::StatementInvalid in SessionsController#create
SQLite3::SQLException: no such column: users.provider: SELECT "users".* FROM "users" WHERE "users"."provider" = 'facebook' AND "users"."uid" = 'FACEBOOK KEY' ORDER BY "users"."id" ASC LIMIT 1
Extracted source (around line #6):
4 def self.from_omniauth(auth)
5 where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
6 user.provider = auth.provider
7 user.uid = auth.uid
8 user.name = auth.info.name
Rails.root:/selfstarter
Application Trace | Framework Trace | Full Trace
app/models/user.rb:6:in `from_omniauth'
app/controllers/sessions_controller.rb:3:in `create'
下面是user.rb中的代码
class User < ActiveRecord::Base
has_many :orders
def self.from_omniauth(auth)
where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user|
user.provider = auth.provider
user.uid = auth.uid
user.name = auth.info.name
user.oauth_token = auth.credentials.token
user.oauth_expires_at = Time.at(auth.credentials.expires_at)
user.save!
end
end
end
class用户
下面是来自会话控制器的代码
class SessionsController < ApplicationController
def create
user = User.from_omniauth(env["omniauth.auth"])
session[:user_id] = user.id
redirect_to root_path
end
def destroy
session[:user_id] = nil
redirect_to root_path
end
end
class sessioncontroller
在用户
表中是否有提供程序
列?您是否错过了将提供程序
列添加到用户
表中的迁移?在用户表中有一个提供程序列,我也运行了迁移,但仍然收到相同的错误