I find hard to work with rest and custom actions. I have an action def logout session[:user = nil end for controller user. In my view I call <%= link_to "Logout'', :action => ''logout''. When I click on link the error is: Couldn''t find Ruser with ID=logout My routes.rb has resources :rusers. How I must call logout action? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
you have a typo on your model name in controller. On Fri, Sep 10, 2010 at 4:59 AM, Mauro <mrsanna1-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I find hard to work with rest and custom actions. > I have an action > > def logout > session[:user = nil > end > > for controller user. > In my view I call <%= link_to "Logout'', :action => ''logout''. > When I click on link the error is: > > Couldn''t find Ruser with ID=logout > > My routes.rb has resources :rusers. > How I must call logout action? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 10, 7:52 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> you have a typo on your model name in controller. > > On Fri, Sep 10, 2010 at 4:59 AM, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I find hard to work with rest and custom actions. > > I have an action > > > def logout > > session[:user = nil > > end > > > for controller user. > > In my view I call <%= link_to "Logout'', :action => ''logout''. > > When I click on link the error is: > > > Couldn''t find Ruser with ID=logout > > > My routes.rb has resources :rusers. > > How I must call logout action? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > >There appear to be several typos: session[:user = nil should be: session[:user = nil] (missing ]) <%= link_to "Logout'', :action => ''logout''. should be: <%= link_to ''Logout'', :action => ''logout'' %> (inconsistent " and '' around Logout; and missing %> ) My routes.rb has resources :rusers. Try putting the following line into routes.rb: map.connect ''user/logout'', :controller => ''user'', :action => ''logout'' -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Couldn''t find Ruser with ID=logout> > > My routes.rb has resources :rusers.the above means your user model has a diferent name than the one you are usign On Fri, Sep 10, 2010 at 9:40 AM, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Sep 10, 7:52 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > you have a typo on your model name in controller. > > > > On Fri, Sep 10, 2010 at 4:59 AM, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I find hard to work with rest and custom actions. > > > I have an action > > > > > def logout > > > session[:user = nil > > > end > > > > > for controller user. > > > In my view I call <%= link_to "Logout'', :action => ''logout''. > > > When I click on link the error is: > > > > > Couldn''t find Ruser with ID=logout > > > > > My routes.rb has resources :rusers. > > > How I must call logout action? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > > There appear to be several typos: > > session[:user = nil > should be: > session[:user = nil] (missing ]) > > <%= link_to "Logout'', :action => ''logout''. > should be: > <%= link_to ''Logout'', :action => ''logout'' %> (inconsistent " and '' > around Logout; and missing %> ) > > My routes.rb has resources :rusers. > Try putting the following line into routes.rb: > map.connect ''user/logout'', :controller => ''user'', :action => ''logout'' > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 September 2010 15:40, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Sep 10, 7:52 am, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> you have a typo on your model name in controller. >> >> On Fri, Sep 10, 2010 at 4:59 AM, Mauro <mrsan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > I find hard to work with rest and custom actions. >> > I have an action >> >> > def logout >> > session[:user = nil >> > end >> >> > for controller user. >> > In my view I call <%= link_to "Logout'', :action => ''logout''. >> > When I click on link the error is: >> >> > Couldn''t find Ruser with ID=logout >> >> > My routes.rb has resources :rusers. >> > How I must call logout action? >> >> > -- >> > You received this message because you are subscribed to the Google Groups >> > "Ruby on Rails: Talk" group. >> > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >> > To unsubscribe from this group, send email to >> > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> > . >> > For more options, visit this group at >> >http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > There appear to be several typos: > > session[:user = nil > should be: > session[:user = nil] (missing ])Or should be session[:user] = nil Is that the same? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 September 2010 16:13, radhames brito <rbritom-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Couldn''t find Ruser with ID=logout >> >> > My routes.rb has resources :rusers. > > > > > the above means your user model has a diferent name than the one you are > usignI think it is correct. Model is Ruser, resources :rusers is set by scaffold I have not set it. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Msan Msan wrote:> On 10 September 2010 15:40, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> > �session[:user = nil >>> >>> >> There appear to be several typos: >> >> �session[:user = nil >> �should be: >> �session[:user = nil] (missing ]) > > Or should be session[:user] = nil > Is that the same?No, Sandy was in error. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 10 September 2010 15:40, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > My routes.rb has resources :rusers. > Try putting the following line into routes.rb: > map.connect ''user/logout'', :controller => ''user'', :action => ''logout''But....I have to set a route for every custom action that I add to controller? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Msan Msan wrote:> On 10 September 2010 15:40, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> �My routes.rb has �resources :rusers. >> �Try putting the following line into routes.rb: >> �map.connect ''user/logout'', :controller => ''user'', :action => ''logout'' > > But....I have to set a route for every custom action that I add to > controller?Yes. . . and No. If you insist on using a custom method in your controller then yes, you will have to specify a route for it. However, you really should be looking at things from the point of view of utilizing only the basic crud actions of create, show, update and delete. Consider what the verb logout implies. Logout from what? A session? Then what are we actually doing with respect to a session? Deleting it? Then perhaps the problem is that you really need another controller, say user_sessions_controller, and that the delete action in that controller is what should perform the logout action. Keep in mind that in web applications speaking of logging in and out is at best a very shaky metaphor and not a description of what is really happening. One does not log on to a web application, one creates an authenticated session. So long as that session persists then the browser can consume the private resources provided by the web app. Once the session is destroyed then the browser cannot consume those resources. In my opinion, this is the secret to thinking about REST, putting everything in terms of the four basic verbs. If you are thinking in terms of custom methods then you are probably not thinking REST. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Either that, or (not recommended really) you can enable the catch all route in routes.rb by uncommenting the line towards the bottom that looks like: match '':controller(/:action(/:id(.:format)))'' but read the line above that, which tells you that if you do that, you''ll enable access to all actions in all controllers; probably not what you want to do. On Sep 10, 2010, at 2:04 PM, Mauro wrote:> On 10 September 2010 15:40, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> My routes.rb has resources :rusers. >> Try putting the following line into routes.rb: >> map.connect ''user/logout'', :controller => ''user'', :action => ''logout''This would be correct if you were on rails 2, but according to your earlier post, you said you''ve got resources :rusers, which would only work in rails3, I think. So, to add the custom route, do this: match ''/rusers/logout'' :to=>''rusers#logout'' Go here and do some reading: http://edgeguides.rubyonrails.org/routing.html That should give you plenty to chew on and at least make the simple routing stuff clear. Hope that helps you.> > But....I have to set a route for every custom action that I add to controller? > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 11 September 2010 04:46, James Byrne <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Msan Msan wrote: >> On 10 September 2010 15:40, Sandy <sandy.asman-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >>> >>> �My routes.rb has �resources :rusers. >>> �Try putting the following line into routes.rb: >>> �map.connect ''user/logout'', :controller => ''user'', :action => ''logout'' >> >> But....I have to set a route for every custom action that I add to >> controller? > > Yes. . . and No. > > If you insist on using a custom method in your controller then yes, you > will have to specify a route for it. However, you really should be > looking at things from the point of view of utilizing only the basic > crud actions of create, show, update and delete. > > Consider what the verb logout implies. Logout from what? A session? > Then what are we actually doing with respect to a session? Deleting it? > Then perhaps the problem is that you really need another controller, say > user_sessions_controller, and that the delete action in that controller > is what should perform the logout action.So I''ve to do something like this? class SessionsController < ApplicationController def destroy session[:cas_user] = nil session.delete(:casfilteruser) CASClient::Frameworks::Rails::Filter.logout(self, rusers_url) end end and in html.erb page: <%= link_to ''Logout'', :controller => ''sessions'', :action => ''destroy'' %> I think it is still not REST. I''m confused. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 10, 1:58 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Msan Msan wrote: > > On 10 September 2010 15:40, Sandy <sandy.as...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> > session[:user = nil > > >> There appear to be several typos: > > >> session[:user = nil > >> should be: > >> session[:user = nil] (missing ]) > > > Or should be session[:user] = nil > > Is that the same? > > No, Sandy was in error.Marmen was correct. The missing ] belonged where he showed it. Sorry about any confusion.> > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.