Get vs Post

Derek Williams
Jul 23, 2017 · 2 min read

I want to write a web site and I need to make sure that it follows the restful rules. But how do I know when to use Get or Post? It’s actually quite simple.


To start, you must know what you are trying to do. Before throwing in random options(get, post, delete), make sure you THINK about what your end goal is. With this in mind began your line of code.

get "/test" => "example#index"

We’ll start with get since that tends to go first. Get is used when you are trying to just write something on a regular page, that doesn’t do anything but show people some text or maybe an image. This is the most common of the two and most used.

post "/test" => "example#create"

Next, we will talk post. Post is only used when trying to send something out. Such as a New Profile. maybe you want to have someone sign up and send their profile to your database or send them to another page. Using the post will enable you to do so. But when ever there is a post, there is a get, so it’s less of a vs as much as it is a mutual agreement.


In the end, both get and post works well together to make an awesome web site, sometimes using things outside of the restful ways, is best.

get "example" => "test#index"get "example" => "test#index"
get "example/new" => "test#new"
post "example" => "test#create"
get "example/:id" => "test#show"
get "example/:id/edit" => "test#edit"
get "example_search" => "test#search"get "/signup" => "users#new"
post "/users" => "users#create"
get "/login" => "sessions#new"
post "/login" => "sessions#create"
get "/logout" => "sessions#destroy"
Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade