大家好,我有一个问题(帖子的标题)。
这是我的
Failure/Error: get :create, :user => { :email => 'foo@example.com', :name => 'userexample' }
ActionController::RoutingError:No route matches {:action=>"show", :controller=>"user", :id=>nil}
这是我的
UserController
。class UserController < ApplicationController
def new
end
def create
@user = User.new(params[:user])
@user.save
redirect_to :action => :show, :id => @user.id
end
def show
@user = User.find(params[:id])
end
end
这是我的routes.rb文件:
::Application.routes.draw do
devise_for :users
root :to => "user#index"
resources :user
#match "newuser" => "user#new"
get "user/new"
post "user/create"
get "user/:id" => "user#show"
以下是我的rspec测试
require 'spec/spec_helper'
describe UserController do
it "create new user" do
get :create, :user => { :email => 'foo@example.com', :name => 'userexample' }
flash[:notice] = 'new user was successfully created.'
end
end
end
redirect_to new_user_path
。 - MrDanA