DEV Community

Ivana
Ivana

Posted on • Originally published at Medium on

1

RESTful Conventions in Rails

What is REST?

By definition Representational state transfer (REST) is a software architectural style that defines a set of constraints to be used for creating Web services. REST was defined by Roy Fielding in his 2000 PhD dissertation. It’s a standard way web apps should structure their URLs. It provides a way of mapping HTTP verbs ( get, post, put, delete) and CRUD actions (create, read, update, delete) together.

Rails

Rails has RESTful principles built into its core. There are seven RESTful route options available, that match the HTTP verbs and allow us to perform CRUD (Create, Read, Update, Delete) actions. Routes are the code that are responsible for listening and receiving requests and then deciding what to send back. The routes we’ll start with will allow us to gather data and present it:

The last 3 routes will mutate that data:

RESTful routes have a clear mapping between the URL resource and the corresponding controller actions. Here is a mapping of all of the different route helpers, HTTP verbs, paths, and controller action mappings:

The beauty of following these conventions is that you don’t have to reinvent the wheel every time you build a new CRUD app, the routes and method names have already been decided.

Connect with Me on Twitter or LinkedIn

Originally published at https://ivanadokic.github.io on February 17, 2020.

Sentry blog image

How to reduce TTFB

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

In this article, we’ll see how we can identify what makes our TTFB high so we can fix it.

Read more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay