Rails CRUD to remember

Aw, CRUD. I Need Some REST.

For a while now I’ve been confusing CRUD and REST. It’s easy to do so when you speed through a full stack web development curriculum in the span of three months at the moment, so now that I’m “finished with three projects,” it’s time to really solidify the concepts.


Representational state transfer, known as REST for short, is a standard architectural style that makes up the world wide web. It was introduced by Roy Fielding in 2000 and refers to the use of standard HTTP verbs to describe a request and the action the server should take in response. REST is useful because it’s predictable, scalable, and simple, especially since it encourages the re-use of URIs. In other words, you can have the same URI respond differently to different verbs.

Breakdown of HTTP Verbs

GETis usually used to list a collection of data, or one of the items in a collection. It purely displays information. You can GET '/resources' or a single '/resource/1' where the digit represents the resource's database id.


CRUD actions, on the other hand, refer to the “basic functions of persistent storage,”. CRUD is an acronym for Create, Read, Update, and Delete.

Best Practices, CRUD + REST

A best practice many software developers/students follow is to keep your routes RESTful. For the longest time, I thought that meant using only CRUD actions in a controller, but the reality is that non-CRUD controller actions can still be RESTful, so long as the appropriate HTTP verbs are used to describe the action that takes place. For example: a GET request that maps to a controller action called more_studentswhich is a version subset of studentsand returns just a list of displayed students is still RESTful. You can call the controller actions whatever you want, really, but for the sake of your future sanity and the sanity of your fellow developers, try to stick to conventions. What you wouldn't want to do is issue a POST request to fetch a list of resources or something. Or make a GET request delete a resource. That would be insane. Don't do it!



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store