Skip to content

Instantly share code, notes, and snippets.

@gabebw
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save gabebw/ae0bd8115883010d4f46 to your computer and use it in GitHub Desktop.

Select an option

Save gabebw/ae0bd8115883010d4f46 to your computer and use it in GitHub Desktop.
Routes as objects

Routes and their Objects

Note that show paths and index paths are not arrays.

The object to use is what you'd pass to form_for, link_to, or redirect_to.

Name at /rails/info/routes object to use path
root_path no object-oriented way. Need to use root_path /
gallery_images_path [@gallery, :images] /gallery/1/images
new_gallery_image_path [:new, @gallery, :image] /gallery/1/images/new

| | edit_gallery_image_path | [:edit, @gallery, @image] | /gallery/1/images/edit | | gallery_image_path | [@gallery, @image] | /gallery/1/images/1 | | galleries_path | :galleries | /galleries | | new_gallery_path | [:new, :gallery] | /galleries/new | | edit_gallery_path | [:edit, @gallery] | /galleries/1/edit | | gallery_path | @gallery | /galleries/1 |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment