ActiveRecord::StatementInvalid: Could not find table 'users'

ruby-on-rails

Solution

You can check to see if `db/test.sqlite3` is empty. In that case, run `rake db:test:prepare`

Problem

I am learning Ruby on Rails Tutorial, I have finished the chapter 7 and it works well, but come across 25 failures/errors like the following: User Failure/Error: @user = User.new(name: "Example User", email: "user@example.com", ActiveRecord::StatementInvalid: Could not find table 'users' # ./spec/models/user_spec.rb:18:in `new' # ./spec/models/user_spec.rb:18:in`block (2 levels) in ' This is the 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 ``` Thanks for your help.

Original source