A library for "one off" announcements in Rails apps.
MIT License
paul_revere has been deprecated. We recommend using the noticed gem.
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...
Announcement
, which has timestamps and a "body" text column.current
class method on Announcement
which returns the latestAnnouncement
, or a new unsaved instance.#current_announcement
, which will return that latestAnnouncement
record._public_announcement
, which is intended to be shown to_private_announcement
, which is intended to be shown_email_announcement
, which is intended to be used inFor 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 Copyright © 2009 thoughtbot, inc. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
This repo is maintained and funded by thoughtbot, inc. The names and logos for thoughtbot are trademarks of thoughtbot, inc.
We love open source software! See our other projects. We are available for hire.