Ruby on rails ActiveRecord::语句无效:找不到表';用户';
我正在学习Ruby on Rails教程,我已经完成了第7章,它工作得很好,但是遇到了如下25个失败/错误: 使用者 失败/错误:@user=user.new(名称:“示例用户”,电子邮件:user@example.com", ActiveRecord::语句无效: 找不到表“用户” #./spec/models/user_spec.rb:18:inRuby on rails ActiveRecord::语句无效:找不到表';用户';,ruby-on-rails,Ruby On Rails,我正在学习Ruby on Rails教程,我已经完成了第7章,它工作得很好,但是遇到了如下25个失败/错误: 使用者 失败/错误:@user=user.new(名称:“示例用户”,电子邮件:user@example.com", ActiveRecord::语句无效: 找不到表“用户” #./spec/models/user_spec.rb:18:innew' #./spec/models/user_spec.rb:18:in块(2层)in' 这是users_controller.rb class
new'
#./spec/models/user_spec.rb:18:in
块(2层)in'
这是users_controller.rb
class UsersController < ApplicationController
def new
@user = User.new
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(params[:user])
if @user.save
flash[:success] = "Welcome to the Sample App!"
redirect_to @user
else
render 'new'
end
end
end
class UsersController
谢谢您的帮助。您可以检查
db/test.sqlite3
是否为空。在这种情况下,在Rails 3.2或最新版本中运行rake db:test:prepare,只需执行:rake db:test:prepare即可