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

On 13 September 2010 16:02, radhames brito [email protected] wrote:

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,

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

Msan M. wrote:

On 13 September 2010 16:02, radhames brito [email protected] wrote:

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,

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

Perhaps you should be using a singleton resource for sessions the way
Authlogic does?

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

i think you should,

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

@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

On Mon, Sep 13, 2010 at 3:38 PM, Daniel Gaytán
<[email protected]

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

2010/9/13 radhames brito [email protected]

yes i agree

On Mon, Sep 13, 2010 at 3:57 PM, Daniel Gaytán
<[email protected]

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

2010/9/13 radhames brito [email protected]

no, that his is a way to build the route

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

On Mon, Sep 13, 2010 at 3:00 PM, radhames brito [email protected]
wrote:

yes i agree

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


Greg D.
destiney.com | gregdonald.com

On 14 September 2010 09:14, Mauro [email protected] wrote:

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.

On 13 September 2010 21:57, Daniel Gaytán
[email protected]wrote:

Then it may be set as resource instead of resources

or maybe

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”}

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs