2016-06-07 58 views
0

任何人都可以帮我吗? 我正在使用设备与rails进行身份验证。 我有这些控制器:没有路由匹配[POST]“/ users/sign_up”

Users::RegistrationsController < Devise::RegistrationsController 

我用下面这个控制器与不同的标准

class UsersController < ApplicationController

下面列表中的用户是我的路线:

devise_for :users, 
     :controllers => { 
      :registrations => "users/registrations" 
      } 

resources :users, :only => [:index, :show, :mentor_list] do collection do get 'leaders' => 'users#leaders_list' get 'mentors' => 'users#mentors_list' get 'students' => 'users#students_list' end resources :addresses end

bel ow是我的耙路线结果:

new_user_session GET /users/sign_in(.:format)       devise/sessions#new 
      user_session POST /users/sign_in(.:format)       devise/sessions#create 
    destroy_user_session DELETE /users/sign_out(.:format)       devise/sessions#destroy 
      user_password POST /users/password(.:format)       devise/passwords#create 
     new_user_password GET /users/password/new(.:format)      devise/passwords#new 
     edit_user_password GET /users/password/edit(.:format)      devise/passwords#edit 
         PATCH /users/password(.:format)       devise/passwords#update 
         PUT /users/password(.:format)       devise/passwords#update 
cancel_user_registration GET /users/cancel(.:format)       users/registrations#cancel 
     user_registration POST /users(.:format)         users/registrations#create 
    new_user_registration GET /users/sign_up(.:format)       users/registrations#new 
    edit_user_registration GET /users/edit(.:format)        users/registrations#edit 
         PATCH /users(.:format)         users/registrations#update 
         PUT /users(.:format)         users/registrations#update 
         DELETE /users(.:format)         users/registrations#destroy 
      leaders_users GET /users/leaders(.:format)       users#leaders_list 
      mentors_users GET /users/mentors(.:format)       users#mentors_list 
      students_users GET /users/students(.:format)       users#students_list 
      user_addresses GET /users/:user_id/addresses(.:format)    addresses#index 
         POST /users/:user_id/addresses(.:format)    addresses#create 
     new_user_address GET /users/:user_id/addresses/new(.:format)   addresses#new 
     edit_user_address GET /users/:user_id/addresses/:id/edit(.:format)  addresses#edit 
      user_address GET /users/:user_id/addresses/:id(.:format)   addresses#show 
         PATCH /users/:user_id/addresses/:id(.:format)   addresses#update 
         PUT /users/:user_id/addresses/:id(.:format)   addresses#update 
         DELETE /users/:user_id/addresses/:id(.:format)   addresses#destroy 
        users GET /users(.:format)         users#index 
        user GET /users/:id(.:format)        users#show 
        root GET /            users#index 

所以我想在这里做的是让领导创建用户。但是,每当我点击新的用户窗体的提交按钮时,我会在下面看到这个错误。

Routing Error 

No route matches [POST] "https://stackoverflow.com/users/sign_up" 

预先感谢帮助。

+0

您不能使用“/ users/sign_up”,因为它是GET路线,请检查您的耙路线。 –

+0

那么你的建议是什么 – Idriss

+0

你的注册表格是错误的地方。如果你使用POST,你应该将它发送到'user_registration_path'。 – tadman

回答

1

从您的耙路线 o/p明显看出未定义过用户/注册牌

 user_registration POST /users(.:format)         users/registrations#create 

使用以下路径创建用户。

+0

谢谢,那么我如何根据我的路线定义它? – Idriss

+0

根据评论,看起来像你解决。如果没有,我会帮忙。还在github上查看设计文档页面。 – Bijendra