Escaping the REST Prison

While REST is extremely powerful, developers used to working in other environments may be cursing at this point, wondering whether they really need to build every part of their application according to this weird new paradigm.

Don’t worry: you don’t have to. You could, if you wanted, stick with the GET/POST approach shown in earlier chapters. Rails doesn’t enforce RESTfulness.

However, you may want to explore a combination of approaches. If a page is only ever going to be reached with GET, use a simple controller and view or even a static page where appropriate. If a page needs to manage more sophisticated data input and output, then use REST to simplify that process. In a more complex application, it might make sense to use REST for cases where data is coming in or being edited, and to use simpler controllers for situations where the application is just presenting information.

The remainder of this book is going to use the combination approach. REST is just too convenient for getting structured data in and out of a website to ignore, but when REST isn’t necessary, there’s no need to let it dominate.

Get Learning Rails 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.