Reputation: 5859
I was trying to implement a logout option in my rails app. To implement it, I followed this SO answers. But I am getting errors.
Why is this occuring?
My routes for this controller
login GET /login(.:format) sessions#new
sessions GET /sessions(.:format) sessions#index
POST /sessions(.:format) sessions#create
new_session GET /sessions/new(.:format) sessions#new
edit_session GET /sessions/:id/edit(.:format) sessions#edit
session GET /sessions/:id(.:format) sessions#show
PATCH /sessions/:id(.:format) sessions#update
PUT /sessions/:id(.:format) sessions#update
DELETE /sessions/:id(.:format) sessions#destroy
Upvotes: 1
Views: 112
Reputation: 2012
try: <%= link_to 'Log Out', session_path(current_user), :method => :delete %>
The session_path
method takes a parameter which determines the id of the User object. Also be sure to use <%=
when you want to render the line instead of <%
Upvotes: 1