I am trying to destroy a session created by Restful authentication
plugin, but everything I’ve tried doesn’t work. I’ve been googling
for a while but haven’t found anything that will fix this.
These are the relevant lines that I currently have:
config/routes.rb:
map.resource :session, :member => {:logoff => :delete }
app/views/layouts/credentials.html.erb:
<%= link_to “logout”, logoff_session_url %>
Session Routes from ‘rake routes’:
POST /session
{:controller=>“sessions”, :action=>“create”}
POST /session.:format
{:controller=>“sessions”, :action=>“create”}
new_session GET /session/new
{:controller=>“sessions”, :action=>“new”}
formatted_new_session GET /session/new.:format
{:controller=>“sessions”, :action=>“new”}
edit_session GET /session/edit
{:controller=>“sessions”, :action=>“edit”}
formatted_edit_session GET /session/edit.:format
{:controller=>“sessions”, :action=>“edit”}
logoff_session DELETE /session/logoff
{:controller=>“sessions”, :action=>“logoff”}
formatted_logoff_session DELETE /session/logoff.:format
{:controller=>“sessions”, :action=>“logoff”}
session GET /session
{:controller=>“sessions”, :action=>“show”}
formatted_session GET /session.:format
{:controller=>“sessions”, :action=>“show”}
PUT /session
{:controller=>“sessions”, :action=>“update”}
PUT /session.:format
{:controller=>“sessions”, :action=>“update”}
DELETE /session
{:controller=>“sessions”, :action=>“destroy”}
DELETE /session.:format
{:controller=>“sessions”, :action=>“destroy”}
And the layout generates the following html:
When I click on the logoff link, here is the error that shows up on
the resulting page:
ActionController::MethodNotAllowed
Only delete requests are allowed.
I know that the url has to somehow signify that the delete method is
to be used since web browsers don’t support the delete method, but I’m
not sure what I’m doing wrong. Can anybody help?
Thanks,
Jonathan