Add Pages

Let’s begin adding pages to our web application.

There are three types of web pages in a Rails application. We’ve looked
at two types so far:

    static pages in the public/ folder that contain no Ruby code
    dynamic pages such as our home page that use the application layout

There’s another type of web page that is required on many websites. It
has static content; that is, no dynamic data is needed on the page. But
it uses the default application layout to maintain consistency in the
website look and feel. We classify this type of page as a:

    static view that uses the application layout

Examples include:

    “About” page
    Legal page
    FAQ page

It’s possible to place these pages in the public/ folder and copy the
HTML and CSS from the default application layout but this leads to
duplicated code and maintenance headaches. And dynamic elements such as
navigation links can’t be included. For these reasons, developers seldom
create static pages in the public/ folder.

Alternatively, a dynamic page can be created that has no model, a
nearly-empty controller, and a view that contains no instance variables.
This solution is quite common for static views that use the application
layout.

This solution is implemented so frequently that many developers create a
gem to encapsulate the functionality. We’re going to use the best-known
of these gems, the high_voltage gem created by the Thoughtbot consulting
firm.

We’ll use the High Voltage gem to create an “About” Page.

We also will create a Contact page. We’ll again use the High Voltage
gem, but only for the first version of the Contact page. Later we’ll
discard the page we created with the High Voltage gem and replace it
with a full model-view-controller implementation.