我正在学习
Ruby on Rails教程,我已经完成了第7章并且它运行良好,但遇到了25个失败/错误,如下所示:
用户
失败/错误:@ user = User.new(名称:“示例用户”,电子邮件:“user@example.com”,
ActiveRecord的:: StatementInvalid:
找不到表’用户’
#./spec/models/user_spec.rb:18:in new’
‘./spec/models/user_spec.rb:18:inblock(2 levels)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
谢谢你的帮助.
解决方法
您可以检查db / test.sqlite3是否为空.在这种情况下,运行rake db:test:prepare