Skip to content

Instantly share code, notes, and snippets.

@harryworld
Created October 21, 2014 02:59
Show Gist options
  • Save harryworld/777c40cf9bff916cb25e to your computer and use it in GitHub Desktop.
Save harryworld/777c40cf9bff916cb25e to your computer and use it in GitHub Desktop.
Using http methods in Rails
  • What method should I use?
<form action="/search" method="">
  <input type="text" name="p" value="">
  <input type="submit">
</form>
  • What method should I use?
<form action="/tweets" method="">
  <input type="text" name="content" value="">
  <input type="submit">
</form>
  • What method should I use?
<form action="/comments/1" method="">
  <input type="text" name="comment" value="">
  <input type="submit">
</form>
  • When do we use PUT vs PATCH? with example.

  • When do we use DELETE? with example.

@harryworld
Copy link
Author

GET - Retrieve information without change server state
POST - Create new resource
PATCH - Update resource (default method since Rails 4)
PUT - Update resource
DELETE - Delete a resource

Edge Rails: PATCH is the new primary HTTP method for updates
http://weblog.rubyonrails.org/2012/2/26/edge-rails-patch-is-the-new-primary-http-method-for-updates/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment