Session destroy link won't work

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:

logout

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

On Oct 6, 5:25 am, JHuizingh [email protected] wrote:

And the layout generates the following html:

logout

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.

Well you’ve sort of figured it out yourself - Your routing demands a
DELETE method, but your link is a plain old GET.
Either you change your routing to accept GET requests or you use
the :method option to link_to to fake up a DELETE request (watch out,
this relies on javascript)

Fred

Thank you. That was it. I could have sworn that I tried that, but I
guess something else must have been wrong when I tried it. It works
now. Thanks.

Jonathan

On Oct 6, 1:45 am, Frederick C. [email protected]