Skip to content

Instantly share code, notes, and snippets.

@ambethia
Created June 24, 2015 00:23
Show Gist options
  • Save ambethia/47eee455fe12c4e49c0e to your computer and use it in GitHub Desktop.
Save ambethia/47eee455fe12c4e49c0e to your computer and use it in GitHub Desktop.
resources :books
# is short hand for:
get 'books' => 'books#index' #as => 'books'
post 'books' => 'books#create' #as => 'books'
get 'books/new' => 'books#new', :as => 'new_book'
get 'books/:id/edit' => 'books#edit', :as => 'edit_book'
get 'books/:id' => 'books#show', :as => 'book'
patch 'books/:id' => 'books#update' #as => 'book'
put 'books/:id' => 'books#update' #as => 'book'
delete 'books/:id' => 'books#destroy' #as => 'book'
# both generate the exact same routes:
# Prefix Verb URI Pattern Controller#Action
# books GET /books(.:format) books#index
# " POST /books(.:format) books#create
# new_book GET /books/new(.:format) books#new
# edit_book GET /books/:id/edit(.:format) books#edit
# book GET /books/:id(.:format) books#show
# " PATCH /books/:id(.:format) books#update
# " PUT /books/:id(.:format) books#update
# " DELETE /books/:id(.:format) books#destroy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment