wood burning stoves 2.0*
The moose likes Ruby and the fly likes problem understanding routes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "problem understanding routes" Watch "problem understanding routes" New topic
Author

problem understanding routes

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Hi All,
I am still fairly new to ruby and rails, and so may not have the correct vocabulary to even ask this question.
I have a form which posts to a save method in an action, this action path is very easy to understand, go to tasks_controller and go to save method there.


What is confusing me is this route at the very end of the save method in tasks_controller.rb.


What confuses me here is that there is no method name, just the task controller name. This redirect ends up calling the method "show" in the same controller. My question is why? How does it know to call the show method when it just mentions the controller name ?

Thanks for any help!
Kim
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

_path and _url helper methods are very smart.

In customer_project_task_path, "task" is singular, so it will default to the path for the :show action.

Here's a good cheatsheet for the conventions:
http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf


A good workman is known by his tools.
Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 274
Marc, this is EXACTLY the kind of information I needed!! Can't thank you enough.
Some times when you are new to something, its hard to even know what you are looking for. I have spent hours on different sites and in books but was having no luck. It was driving me crazy not understanding why the path was working that way.

Thank you again so much!
Kim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem understanding routes
 
Similar Threads
JSP/ HTML ?
How exactly controller controls the flow
struts Action for asynchronous HTTP processing
execute method not being called
Is ActionForm is part of controller or view