what I've missed in routes.rb?

In routes.rb I've put:

resources :sessions

controller is:

class SessionsController < ApplicationController

def destroy    session[:id] = nil    session.delete(:casfilteruser)    CASClient::Frameworks::Rails::Filter.logout(self) end

end

In application.html.erb I have:

<%= link_to 'Logout', session_path(session[:cas_user]), :method => :delete %>

I think it's all but:

No route matches {:action=>"destroy", :controller=>"sessions", :id=>"name.surname"}

What I've missed?

you dont need to pass this session[:cas_user]

the default destroy route is /controller/id , :method=> delete {:action=>“destroy”, :controller=>“sessions”, :id=>“name.surname”}

but your destroy action does not need an id really, the other problem is that you dont need an id but pass

session_path(session[:cas_user])

and then not use it becuase you do this

session[:id] = nil

im not user if yo want to do this

session[:cas_user] = nil

So I've to change the default destroy route for sessions resource?

Msan Msan wrote:

i think you should,

resources user, :except => :destroy then match you path here

I think you are missing the rails javascript file, which is who actually handles the special links.

When you click on the link, the method is GET, so you don’t hace any toute related to the action destroy in that method.

Daniel Gaytán

@Daniel Gaytán

but the default destroy route will still wait for an id, and he doesnt needs if since the user is in the session

Then it may be set as resource instead of resources

or maybe

resources :something, :except => :destroy do delete :destroy, :on => :collection, :as => :destroy end

Daniel Gaytán

yes i agree

That you don't know how to trim a post?

no, that his is a way to build the route

resources :something, :except => :destroy do delete :destroy, :on => :collection, :as => :destroy end

If I do

resources :sessions, :except => :destroy do

delete :destroy, :on => :collection, :as => :destroy

end

Then It call update instead of destroy:

<%= link_to ‘Logout’, session_path, :method => :delete %>

No route matches {:action=>"update", :controller=>"sessions"}

I think I've solved using resource :session. Thanks to all.