O'Reilly logo

Crafting Rails 4 Applications, 2nd Edition by José Valim

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1Creating Our Own Renderer

  • Rails plug-ins and their basic structure

  • How to customize the render method to accept custom options

  • Rails rendering-stack basics

Like many web frameworks, Rails uses the model-view-controller (MVC) architecture pattern to organize our code. The controller usually is responsible for gathering information from our models and sending the data to the view for rendering. On other occasions, the model is responsible for representing itself, and then the view does not take part in the request; this most often happens in JavaScript Object Notation (JSON) requests. The following index action illustrates these two scenarios:

 
class​ PostsController < ApplicationController
 
def​ index
 
if​ client_authenticated? ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required