File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem understanding routes

 
Kim Kantola
Ranch Hand
Posts: 276
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
_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
 
Kim Kantola
Ranch Hand
Posts: 276
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic