File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

problem understanding routes

Kim Kantola
Ranch Hand

Joined: May 17, 2001
Posts: 276
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!
Marc Peabody
pie sneak

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:

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

Joined: May 17, 2001
Posts: 276
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!
I agree. Here's the link:
subject: problem understanding routes
It's not a secret anymore!