REST and Controller Best Practices
REST is an approach to building web applications that takes as much advantage of the underlying structure of the web as possible. This makes a lot of things more comfortable:
Users will find that the applications work as they’d like in their web browsers. They can bookmark pages and come back to them, and the URLs are actually meaningful.
Network administrators can use all their preferred techniques for managing web traffic without worrying about disrupting an application.
You, of course, get the greatest benefits. REST-based architecture is a very neat fit with Rails’ MVC approach, and makes it easier to keep track of which code does what where. Rails 2.x is also set up to make it extremely easy for you to use REST, supporting a number of ways for you to say, “I’d like this to behave RESTfully.”
REST doesn’t create new techniques so much as dust off old techniques and encourage developers to use them as they were designed to be used. Of course, even early in the Web’s development, developers hacked and slashed their way into a different style of programming, so there are some adjustments to make. Fortunately, Rails makes it easy to adjust and opens new horizons in doing so.
Note
REST stands for REpresentational State Transfer, which describes what happens but isn’t the most immediately meaningful explanation.
Websites and Web Applications
Web developers have historically used two HTTP methods to get information into and out of sites: GET and POST. On ...
Get Learning Rails: Live Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.