ruby-on-rails – ActiveRecord :: StatementInvalid:无法找到表’users’

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – ActiveRecord :: StatementInvalid:无法找到表’users’前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在学习 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

  1. class UsersController < ApplicationController
  2. def new
  3. @user = User.new
  4. end
  5.  
  6. def show
  7. @user = User.find(params[:id])
  8. end
  9.  
  10. def create
  11. @user = User.new(params[:user])
  12. if @user.save
  13. flash[:success] = "Welcome to the Sample App!"
  14. redirect_to @user
  15. else
  16. render 'new'
  17. end
  18. end
  19. end

谢谢你的帮助.

解决方法

您可以检查db / test.sqlite3是否为空.在这种情况下,运行rake db:test:prepare

猜你在找的Ruby相关文章