A library for "one off" announcements in Rails apps.
Ruby JavaScript HTML
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
app Spec coverage for announcements js Feb 24, 2015
gemfiles Allow rails version 5.2.0 Apr 13, 2018
lib Bump to v3.0.0 Apr 30, 2018
spec Add sqlite3 boolean configuration option, avoids deprecation warning Apr 13, 2018
.gitignore Add tmp/ to gitignore Dec 17, 2014
.rspec Update project dependencies Dec 17, 2014
Appraisals Allow rails version 5.2.0 Apr 13, 2018
CHANGELOG.md Bump to v3.0.0 Apr 30, 2018
Gemfile Use https url for rubygems Feb 24, 2015
Gemfile.lock Update mini_mime to version 1.0.1 Aug 14, 2018
README.md Update copyright Apr 30, 2018
Rakefile Spec coverage for announcements js Feb 24, 2015


Paul Revere

Build Status

This gem enables the inclusion of "one off" announcements in Rails applications.


First, include the gem as normal in your Gemfile:

gem "paul_revere"

Then, run the generator to create the migration and copy the javascript.

rails generate paul_revere

The announcements JS will be installed into vendor/assets/javascripts. You can add the announcement JS to app/assets/javascripts/application.js:

//= require announcements

This will include the javascript into the application.js for the entire site.

Finally, create the announcements table by running the migration:

rake db:migrate

Copy built-in partials into your Rails application by running:

rails generate paul_revere:views


Paul Revere provides...

  • A model called Announcement, which has timestamps and a "body" text column.
  • A current class method on Announcement which returns the latest Announcement, or a new unsaved instance.
  • A view helper called #current_announcement, which will return that latest Announcement record.
  • A view partial called _public_announcement, which is intended to be shown to all site users.
  • A view partial called _private_announcement, which is intended to be shown only to logged in users. Note that this merely wraps the rendering of the public announcement with a call to a helper which checks that a user is signed in. There is only one type of Announcement.
  • A view partial called _email_announcement, which is intended to be used in site emails which are sent out and need to include announcements.


  • Install the gem, run the migration, ensure the javascript can be accessed.
  • Use those partials in the correct places in your view code and mailer view code where you want announcements to show up.

For example, to include the latest announcement for all site users:

<%= render "announcements/public_announcement" %>

To make an announcement, use the Rails console to create a new record:

Announcement.create!(body: "Free ice cream on Monday!")

There is a helper method called announcement_visibility_allowed?, which is what the private_announcement partial calls to determine whether to allow the current session to view announcements. The built-in implementation just checks that current_user is truth-y. Override that helper method if you want to do something more interesting as a check here.



Paul Revere is maintained and funded by thoughtbot, inc

Thank you to all the contributors!

The names and logos for thoughtbot are trademarks of thoughtbot, inc.


Paul Revere is Copyright © 2009-2018 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.