2016-06-07 110 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