2017-09-23 86 views
1

我在使用Devise的現有應用中運行Rails 5並將Bootstrap更新爲版本4。沒有路由匹配[GET]「/ users/sign_out」** Rails 5/Bootstrap 4 **

更新Bootstrap之前,路由工作正常。現在,當用戶選擇登出,他們收到以下消息:

無路由匹配[GET]「/用戶/ SIGN_OUT」

這裏是標頭碼的一部分:

<% if current_user %> 
    <a class=<%= link_to 'Classes', tracks_path %></a> 
    <a class=<%= link_to 'Edit profile', edit_user_registration_path %></a> 
    <a class=<%= link_to 'Sign out', destroy_user_session_path, method: :delete %></a> 

而且耙路線顯示:

destroy_user_session DELETE /users/sign_out(.:format)設計/會話#破壞

是否有更改Bootstrap 4會引發此錯誤的原因?我遵循Bootstrap回購安裝的所有說明。

+0

見https://stackoverflow.com/questions/7465919/rails-link-to-method-geting-when-it-should-delete – Jaxx

回答

1

的問題是你呈現你的鏈接標籤類屬性:

<a class=<%= link_to 'Sign out', destroy_user_session_path, method: :delete %></a> 

這樣的結果而忽略您指定method: :delete畸形輸出。這是你在找什麼:

<%= link_to "Sign out", destroy_user_session_path, 
    method: :delete, class: 'nav-link' %> 
相關問題