This week's book giveaway is in the Artificial Intelligence and Machine Learning forum.
We're giving away four copies of Succeeding with AI and have Veljko Krunic on-line!
See this thread for details.
Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

problem understanding routes

 
Ranch Hand
Posts: 276
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • 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
  • 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
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic