【问题标题】:ActionController::RoutingError:动作控制器::路由错误:
【发布时间】:2012-07-16 19:38:47
【问题描述】:

我从我的测试中不明白这个错误 Failure/Error: get "new" ActionController::RoutingError: No route matches {:action=>"new", :controller=>"user"}

我的路线文件

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

这是我的测试

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

【问题讨论】:

    标签: ruby-on-rails rspec routing


    【解决方案1】:

    您的控制器哈希不正确。你有:controllers => { :new => "new" },这就是说你希望你的“用户”模型通过一个名为“新”的控制器来处理。这应该更改为,例如:controllers => { :registrations => "registrations" },假设您的控制器的名称是“注册”

    【讨论】:

    • 我的控制器的名字是usercontroler...我改了但是错误仍然存​​在,在原来的控制器中我没有任何代码
    • 基本上我需要一个新用户在网站上注册并带他到个人资料页面
    • 你查看过 github 上的文档吗?特别注意,如果您定义自定义控制器,它应该从适当的设计控制器继承。 github.com/plataformatec/devise
    猜你喜欢
    • 2011-12-11
    • 1970-01-01
    • 2016-07-23
    • 2015-09-26
    • 1970-01-01
    • 2014-08-26
    • 1970-01-01
    • 1970-01-01
    • 2015-02-10
    相关资源
    最近更新 更多