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: "[email protected]",
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.
You can check to see if db/test.sqlite3
is empty. In that case, run rake db:test:prepare
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With