I am adding a simple log out link to my menu bar. It should fire SessionsController#destroy
:
class SessionsController < ApplicationController
#...
def destroy
terminate_session
redirect_to new_session_path
end
end
Here are my routes:
new_session GET /session/new(.:format) sessions#new
edit_session GET /session/edit(.:format) sessions#edit
session GET /session(.:format) sessions#show
PATCH /session(.:format) sessions#update
PUT /session(.:format) sessions#update
DELETE /session(.:format) sessions#destroy
POST /session(.:format) sessions#create
I am creating my link like so: <%= link_to 'Delete', session_path, method: :delete %>
However, when I click on it, Rails looks for the #show
action.
Unknown action
The action 'show' could not be found for SessionsController
How do I for the #destroy
action instead of #show
? Is this a limitation of the browser?
3