抱歉打扰你,但我对这个错误有很多问题。 首先,这是我的user_controller rspec文件
require 'spec/spec_helper'
describe UserController do
it "create new user" do
post "create"
assigns[:users].should_not be_new_record
end
end
这是我的UserController
class UserController < ApplicationController
def create
@users = User.new
if @users.save
flash[:notice] = 'new user was successfully created.'
else
render :action => :new
end
end
def new
@user = User.new
end
end
我的routes.rb文件(我认为问题就在这里,不好意思因为我对这种语言还很陌生)。
Estaciones::Application.routes.draw do
devise_for :users
root :to => "home#index"
resources :user
end
当我尝试测试我的user_controller_rspec时,我遇到了这个错误
失败:
1) UserController create new user
Failure/Error: post "create"
ActiveRecord::StatementInvalid:
PG::Error: ERROR: relation "users" does not exist
LINE 4: WHERE a.attrelid = '"users"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
WHERE a.attrelid = '"users"'::regclass
AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
# ./app/controllers/user_controller.rb:3:in `new'
# ./app/controllers/user_controller.rb:3:in `create'
# ./spec/controllers/user_controller_spec.rb:6
Finished in 0.01722 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/controllers/user_controller_spec.rb:5 # UserController create new user
我该如何解决它...谢谢