我似乎遇到了数据库问题。我一直在使用Rails创建一个网站,我有一个用户数据库。我需要做出改变,所以我耙db:drop,现在我看到了这个错误:
这是我的用户控制器:
*(void **)(&funcptr)
我的用户模型:
class UsersController < ApplicationController
def new
@user = User.new
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
redirect_to @user
else
render 'new'
end
end
private
def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation, :phone_number, :address_one, :address_two, :city, :country, :state, :zip)
end
end
和我当前的用户数据库表
class User < ActiveRecord::Base
has_secure_password
validates :email, presence: true
def self.from_omniauth(auth)
where(provider: auth.provider, uid: auth.id).first_or_create 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.password = "a"
user.email = user.uid
user.save!
end
end
end
感谢您给予的任何建议或帮助!
答案 0 :(得分:1)
迁移文件名和类名应该相同。两者需要保持一致,以便rails动态加载适当的类。
class CreateUsers < ActiveRecord::Migration
将其更改为class Users < ActiveRecord::Migration
运行rake db:migrate