rails-code-snippets.md#

Routes#

3 ways to write the same route#

For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html

Read as function accepting a hash

get(key, value) -> each of these below represents this idiom in 3 different ways to write it

Rails.application.routes.draw do
#  get '/posts', controller: 'posts', action: 'index'
#  get '/posts' => 'posts#index'        ; // this is the conventional way ; 'posts_path'
  get('/posts', {:controller => 'posts', :action => 'index' })

   get 'posts/:id' => 'posts#show'                 # dynamic param "id"
#  get 'posts/:id' => 'posts#show', as: 'post'     # names 'post_path' for helper
end