In the software development world CRUD refers to Create, Read, Update and Delete.

  • Create - This operation would create a brand new entity.
  • READ - This operation would read something from the database but would not make any permanent changes to the database.
  • Update - This operation would change values of an already existing entity.
  • Delete - This operation would delete an entity from the database.

CRUD in action

Let's add following line to config/routes.rb file.

1resources :books

Now let's see all the routes.

1bundle exec rake routes
VERBURI PatternController#ActionUsed forCRUD
GET/booksbooks#indexList booksREAD
POST/booksbooks#createCreate a bookCREATE
GET/books/newbooks#newForm for a new bookREAD
GET/books/:idbooks#editForm for editing bookREAD
GET/books/:idbooks#showShow info about bookREAD
PATCH/books/:idbooks#updateUpdate info about bookUPDATE
PUT/books/:idbooks#updateUpdate info about bookUPDATE
DELETE/books/:idbooks#destroyDelete info about bookDELETE

In the above table for we have added a new column at the end. As we can see each of those seven actions could be assigned to one of these four operations - Create, Read, Update and Delete.

REST vs CRUD

REST is an architectural system to deal with data through HTTP protocols. Typically software applications create RESTful apis to handle CRUD operations.

We are not going to check in changes done to the files.

1git clean -fd