ActiveRecord :: StatementInvalid:无法找到表'users'

时间:2012-05-13 04:18:25

标签: ruby-on-rails

我正在学习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:in阻止(2级)'

这是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

感谢您的帮助。

1 个答案:

答案 0 :(得分:26)

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