简体   繁体   中英

ActionController::RoutingError:

I dont understand this error from my test Failure/Error: get "new" ActionController::RoutingError: No route matches {:action=>"new", :controller=>"user"}

My routes file

Station::Application.routes.draw do devise_for :users, :controllers => { :new => "new" }

and here is my test

require 'spec_helper'
describe UserController do

    it "should registrer new user" do
        get "new"
        fill_in "Email",                 :with => "abc@example.com"
        fill_in "Password",              :with => "abc123"
        click_button "Sign up"
        response.should have_content("Welcome! You have registrered successfully.")
    end 
end

Your controller hash is incorrect. You have :controllers => { :new => "new" } , and what this is saying is that you want your 'User' model to handled by devise through a controller called 'new'. This should be changed to, for example :controllers => { :registrations => "registrations" } , assuming the name of your controller is 'Registrations'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM