Skip to content

Instantly share code, notes, and snippets.

@stevenyap
Created October 18, 2013 13:07
Show Gist options
  • Save stevenyap/7041278 to your computer and use it in GitHub Desktop.
Save stevenyap/7041278 to your computer and use it in GitHub Desktop.
Cheatsheet on Rails Routing Rules

Nested resources

resources :cruises do
  resources :categories
end

Restricting routing to resource

resources :comments, only: [:show, :edit, :update, :destroy]

Default Routings

  • photos_path returns /photos
  • new_photo_path returns /photos/new
  • edit_photo_path(:id) returns /photos/:id/edit (for instance, edit_photo_path(10) returns /photos/10/edit)
  • photo_path(:id) returns /photos/:id (for instance, photo_path(10) returns /photos/10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment