Msan Msan wrote:
> On 10 September 2010 15:40, Sandy <[email protected]> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to