2012-09-18 101 views
1

我試圖讓我所有的色器件的路線是我想他們是方式:制定路由錯誤:沒有路由匹配[PUT]

devise_for :users, :controllers => { :registrations => 'registrations' } 
    devise_scope :user do 
    get 'join' => 'devise/registrations#new', :as => :new_user_registration 
    post 'join' => 'devise/registrations#create', :as => :user_registration 
    get 'login' => 'devise/sessions#new', :as => :new_user_session 
    post 'login' => 'devise/sessions#create', :as => :user_session 
    delete 'logout' => 'devise/sessions#destroy', :as => :destroy_user_session 
    get 'account_settings' => 'devise/registrations#edit', :as => :edit_user_registration 
    put 'account_settings' => 'devise/registrations#update', :as => :update_user_registration 
    get 'forgot_password' => 'devise/passwords#new', :as => :new_user_password 
    get 'user', :to => 'user_pages#home', :as => :user_root 
    end 

    match '/user' => 'user_pages#home', :as => :user_root 

當我去到帳戶設置(或設計編輯註冊)並嘗試更新它。我得到錯誤:

Routing Error 

No route matches [PUT] "/join" 

它假設回到主頁。爲什麼我會得到這個錯誤?我如何解決它?

編輯

這裏的所有的設計路線和那些我做的:

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 
         PUT /users/password(.:format)  devise/passwords#update 
cancel_user_registration GET /users/cancel(.:format)  registrations#cancel 
     user_registration POST /users(.:format)    registrations#create 
    new_user_registration GET /users/sign_up(.:format)  registrations#new 
    edit_user_registration GET /users/edit(.:format)   registrations#edit 
         PUT /users(.:format)    registrations#update 
         DELETE /users(.:format)    registrations#destroy 
    new_user_registration GET /join(.:format)    devise/registrations#new 
     user_registration POST /join(.:format)    devise/registrations#create 
     new_user_session GET /login(.:format)    devise/sessions#new 
      user_session POST /login(.:format)    devise/sessions#create 
    destroy_user_session DELETE /logout(.:format)    devise/sessions#destroy 
    edit_user_registration GET /account_settings(.:format) devise/registrations#edit 
     new_user_password GET /forgot_password(.:format)  devise/passwords#new 

很難讓我看看這個,看看我需要改變。所以如果有人知道它會有很大的幫助。謝謝。

回答

1

執行一條線的變化,我這裏寫全碼:

devise_for :users, :controllers => { :registrations => 'registrations' } 
    devise_scope :user do 
    get 'join' => 'devise/registrations#new', :as => :new_user_registration 
    put 'join' => 'devise/registrations#create', :as => :user_registration 
    get 'login' => 'devise/sessions#new', :as => :new_user_session 
    post 'login' => 'devise/sessions#create', :as => :user_session 
    delete 'logout' => 'devise/sessions#destroy', :as => :destroy_user_session 
    get 'account_settings' => 'devise/registrations#edit', :as => :edit_user_registration 
    put 'account_settings' => 'devise/registrations#update', :as => :update_user_registration 
    get 'forgot_password' => 'devise/passwords#new', :as => :new_user_password 
    get 'user', :to => 'user_pages#home', :as => :user_root 
    end 

    match '/user' => 'user_pages#home', :as => :user_root 

在上面我已經改變了線

post 'join' => 'devise/registrations#create', :as => :user_registration 

put 'join' => 'devise/registrations#create', :as => :user_registration 

或提出請求post請求。

+0

提交新註冊後,會發生以下情況:'沒有路由匹配[POST]「/ join」' – LearningRoR

+0

您做了哪些更改。 –

+0

我把'post'變成'put'就像你剛纔那樣。 – LearningRoR

相關問題