---
title: High Voltage
teaser:
tags: news,web,ruby,rails,high_voltage
author: Dan Croak
published_on: 2009-08-11
---

Last year, we wrote about [static
pages for the enterprise](https://thoughtbot.com/blog/post/159807179/static-pages-for-the-enterprise).

Since then, we've fine-tuned our `PagesController` into a Rails engine called
[High Voltage](http://github.com/thoughtbot/high_voltage).

<object height="313" width="384" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
  <param name="src" value="http://www.youtube.com/v/HD5tnb2RBYg&amp;hl=en&amp;fs=1"
    />
  <embed height="313" width="384" src="http://www.youtube.com/v/HD5tnb2RBYg&amp;hl=en&amp;fs=1"
    type="application/x-shockwave-flash" />
</object>

## Static pages

Yeah, like "About us", "Directions", marketing pages, etc.

## Installation

    script/plugin install git://github.com/thoughtbot/high_voltage.git

## Usage

Write your static pages and put them in the `RAILS_ROOT/app/views/pages`
directory.

    mkdir app/views/pages
    touch app/views/pages/about.html.erb

After putting something interesting there, you can link to it from anywhere in
your app with:

    link_to "About", page_path("about")

Bam.

## Override

Most common reasons to override? Authentication, layouts.

Create a PagesController of your own:

    script/generate controller pages

Then modify it to subclass from High Voltage, adding whatever you need:

    class PagesController < HighVoltage::PagesController
      before_filter :authenticate
      layout "danger"
    end

Don't forget to add the new route:

    map.resources :pages, controller: 'pages', only: [:show]

## Testing

Just a suggestion, but you can test your pages using Shoulda pretty easily:

    class PagesControllerTest < ActionController::TestCase
      tests PagesController

      %w(earn_money screencast about contact).each do |page|
        context "on GET to /pages/#{page}" do
          setup { get :show, :id => page }

          should_respond_with :success
          should_render_template page
        end
      end
    end

Enjoy!
