Skip to content
PLAY VIDEO PLAY VIDEO PLAY VIDEO
By Rachelle LeQuesne

REST and Rails

Note: This post is intended as a supplement to WTF Just Happened? A Quick Tour of Your First Rails App.

REST and Rails

REST is an approach to communications that is often used in the development of Web services. It is one of the defining features of Rails.

HTTP access methods

One of the main features of a REST-based web application is the use of HTTP access methods (also called verbs) when determining how to respond to a request.

HTTP defines four different methods for requesting data:

  • GET
  • POST
  • PUT
  • DELETE

Only two of these methods are in general use: GET for getting information from the server, and POST for putting information onto the server. The other two methods are PUT and DELETE.

A RESTful application uses all of these methods as a meaningful part of the Web action. A GET request results in a show action, the DELETE request triggers the destroy action, the PUT request triggers the update action, and the POST request triggers the create action.

Because HTML forms only handle GET and POST, Rails remains RESTful by wrapping the PUT or DELETE link inside a small POST form with a hidden field that Rails then decodes on the server end.

Resources

A RESTful application is viewed as a set of resources, each of which contains some data and exposes a set of functions to the Web. Within Rails, you do not explicitly define a class called a Resource. Instead, a resource emerges from the interaction of a Controller and a Model with some magic in the route-mapping that ties them together.

In Rails, there are seven standard resource methods for requesting data:

  • show
  • update
  • destroy
  • index
  • create
  • new
  • edit

These will be covered in more detail in MVC and Rails.

You can find an example of how these four HTTP verbs and seven resource methods are implemented in MVC - Controller.

Latest Articles by Our Team

Our expert team of designers and developers love what the do and enjoy sharing their knowledge with the world.

We Hire Only the Best

reinteractive is Australia’s largest dedicated Ruby on Rails development company. We don’t cut corners and we know what we are doing.

We are an organisation made up of amazing individuals and we take pride in our team. We are 100% remote work enabling us to choose the best talent no matter which part of the country they live in. reinteractive is dedicated to making it a great place for any developer to work.

Free Community Workshops

We created the Ruby on Rails InstallFest and Ruby on Rails Development Hub to help introduce new people to software development and to help existing developers hone their skills. These workshops provide invaluable mentorship to train developers, addressing key skills shortages in the industry. Software development is a great career choice for all ages and these events help you get started and skilled up.

  • Webinars

    Webinars

    Webinars are our online portal for tips, tricks and lessons learned in everything we do. Make the most of this free resource to help you become a better developer.

    Learn more about webinars

  • Installfest

    Installfest

    The Ruby on Rails Installfest includes a full setup of your development environment and step-by-step instructions on how to build your first app hosted on Heroku. Over 1,800 attendees to date and counting.

    Learn more about Installfest

  • Development Hub

    Development Hub

    The Ruby on Rails Development Hub is a monthly event where you will get the chance to spend time with our team and others in the community to improve and hone your Ruby on Rails skills.

    Learn more about Development Hub

Get the “reinteractive Review” Monthly Email