---
title: 'Hidden Gems: paul_revere'
teaser: paul_revere is quick one-off announcements for Rails.
tags: web,open source,paul_revere
author: Mike Burns
published_on: 2012-09-14
---

There are times when you must proclaim from the rooftops, for all to hear, that your Web site has something to say! "Hear ye! Hear ye! [The Swedish are coming](https://thoughtbot.com/blog/post/31055415832/hiring-in-stockholm)!", just like Paul Reveresson said.

Thus we have [the paul_revere gem](https://rubygems.org/gems/paul_revere).

![Sample one-off announcement using the paul_revere gem](https://images.thoughtbot.com/blog-vellum-image-uploads/sMk0Zh8RpX1x4jIPv3xA_tumblr_mac0odMn3G1qztl3j.png)

## Install it

To start, toss the gem in your `Gemfile`:

    gem 'paul_revere'

There is an included generator, so be sure to run it:

    rails g paul_revere

This will generate a migration to add an `announcements` table, so run that:

    rake db:migrate

Users of older versions of Rails will see a generated JavaScript file too.

We're almost there. Next up modify your layout to have a place for announcements. In `app/views/layouts/application.html.erb`:

    <%= render 'announcements/announcement_for_all' %>

And finally add the JavaScript to the asset pipeline. In `app/assets/javascripts/application.js`:

    //= require announcements

Whew! A simple process that will only become easier with improvements to Rails.

## Use it

    % rails c
    > Announcement.create!(body: "I'm as mad as hell and that's OK!")

## That was easy

As you just saw, using it is straightforward. This builds on [an
    old RailsCast](https://railscasts.com/episodes/103-site-wide-announcements) dealing with this topic. With these pieces you
  can build more complex tools into your app: an admin section that can
  make announcements, a dashboard where users can see prior
  announcements, a record of how many announcements you make per month,
  and so on.

Don't re-invent the wheel; use the [paul_revere](https://rubygems.org/gems/paul_revere) gem today!
