Chapter 3Retrieving View Templates from Custom Stores

  • How to customize the Rails rendering stack to look up templates from the database

  • How Ruby Hash lookup works

  • How to speed up controllers with ActionController::Metal

When Rails renders a template, it has to get that template from somewhere. By default, Rails serves templates from the filesystem, but it doesn’t need to be limited like that. Rails provides hooks that allow us to retrieve templates from anywhere we want, as long as we implement the required application programming interface (API). Let’s explore this by building a mechanism that lets us serve templates from a database—templates that can be created, updated, and deleted through the web interface. But first let’s take ...

Get Crafting Rails 4 Applications, 2nd 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.