1
votes

I am running Rails 5 and updated Bootstrap to version 4 in an existing app which uses Devise.

Before updating Bootstrap, the routes were working fine. Now, when the user selects sign-out, they receive the following message:

No route matches [GET] "/users/sign_out"

Here is part of the header code:

  <% 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>

And Rake Routes shows:

destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy

Is there a reason that the change to Bootstrap 4 would trigger this error? I have followed all of the instructions on the Bootstrap repo for installation.

1

1 Answers

2
votes

The problem is you're rendering your link tags inside the class attribute:

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

So that results in malformed output which ignores that you specify method: :delete. This is what you're looking for:

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