########################################## Routes ######################################## # RESTful Routes overview GET all the posts (aka “index” the posts) GET just one specific post (aka “show” that post) GET the page that lets you create a new post (aka view the “new” post page) POST the data you just filled out for a new post back to the server so it can create that post (aka “create” the post) GET the page that lets you edit an existing post (aka view the “edit” post page) PUT the data you just filled out to edit the post back to the server so it can actually perform the update (aka “update” the post) DELETE one specific post by sending a delete request to the server (aka “destroy” the post) # RESTful Routes in code get "/posts", to: "posts#index" get "/posts/new", to: "posts#new" get "/posts/:id", to: "posts#show" post "/posts", to: "posts#create" # usually a submitted form get "/posts/:id/edit", to: "posts#edit" put "/posts/:id", to: "posts#update" # usually a submitted form delete "/posts/:id", to: "posts#destroy" # Or one liner for the code above resources :posts # Restrict which routes to generate resources :posts, only: [:index, :show] resources :users, except: [:index] # Init code Rails.application.routes.draw do end # Define root root 'cars#index' ########################################## Controller ##################################### ########################################## Routes ######################################## ########################################## Routes ######################################## ########################################## Routes ########################################
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter