Chapter 5: Models, Views, and Controllers

In Chapter 4, we introduced the principles behind the model-view-controller architectural pattern, and saw how each of the components is implemented within the Rails framework. Now we'll put this knowledge to good use as we use Rails' code generation techniques to create these components for our own Readit application.

Generating a Model

As our application will be used to share links to stories on the Web, a Story is the fundamental object around which our application will evolve. Here, we'll use the Rails model generator to create a Story model, then build everything else around it.

The Model Generator

The model generator is actually driven by a command line script that we encountered back in Chapter ...

Get Rails: Novice to Ninja, 3rd 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.