All Projects → thoughtbot → Paul_revere

thoughtbot / Paul_revere

Licence: mit
A library for "one off" announcements in Rails apps.

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to Paul revere

Kuby Core
A convention over configuration approach for deploying Rails apps. https://getkuby.io
Stars: ✭ 273 (-8.7%)
Mutual labels:  rails
Codecademy Exercise Answers
🎓 Codecademy.com exercise answers
Stars: ✭ 291 (-2.68%)
Mutual labels:  rails
Tapping device
TappingDevice makes objects tell you what they do, so you don't need to track them yourself.
Stars: ✭ 296 (-1%)
Mutual labels:  rails
Pluck to hash
Extend ActiveRecord pluck to return array of hashes
Stars: ✭ 275 (-8.03%)
Mutual labels:  rails
Dockrails
Simple CLI to Generate and Run a Rails environment with Docker (in Development) !
Stars: ✭ 282 (-5.69%)
Mutual labels:  rails
Shoulda Matchers
Simple one-liner tests for common Rails functionality
Stars: ✭ 3,166 (+958.86%)
Mutual labels:  rails
Vue Turbolinks
A Vue mixin to fix Turbolinks caching
Stars: ✭ 272 (-9.03%)
Mutual labels:  rails
Spree starter
Dockerized @spree demo & starter template
Stars: ✭ 297 (-0.67%)
Mutual labels:  rails
Kickoff tailwind
A rapid Rails 6 application template for personal use bundled with Tailwind CSS
Stars: ✭ 287 (-4.01%)
Mutual labels:  rails
Hyper React
The project has moved to Hyperstack!!
Stars: ✭ 295 (-1.34%)
Mutual labels:  rails
Lobsters
Computing-focused community centered around link aggregation and discussion
Stars: ✭ 3,112 (+940.8%)
Mutual labels:  rails
Ar lazy preload
Lazy loading associations for the ActiveRecord models
Stars: ✭ 281 (-6.02%)
Mutual labels:  rails
Timecop
A gem providing "time travel", "time freezing", and "time acceleration" capabilities, making it simple to test time-dependent code. It provides a unified method to mock Time.now, Date.today, and DateTime.now in a single call.
Stars: ✭ 3,110 (+940.13%)
Mutual labels:  rails
Go On Rails
🚄 Use Rails to Develop or Generate a Golang Application.
Stars: ✭ 275 (-8.03%)
Mutual labels:  rails
Siwapp
Online Invoice Management in Ruby On Rails.
Stars: ✭ 296 (-1%)
Mutual labels:  rails
Letters
A tiny debugging library for Ruby
Stars: ✭ 273 (-8.7%)
Mutual labels:  rails
Push type
PushType is a modern, open source content management system for Ruby on Rails.
Stars: ✭ 293 (-2.01%)
Mutual labels:  rails
Lifelong Learning
✅ ✅ ✅ A massive repo filled with notes on everything from coding to philosophy to psychology to marketing to product
Stars: ✭ 297 (-0.67%)
Mutual labels:  rails
Erd
A Rails engine for drawing your app's ER diagram
Stars: ✭ 296 (-1%)
Mutual labels:  rails
Pg party
ActiveRecord PostgreSQL Partitioning
Stars: ✭ 294 (-1.67%)
Mutual labels:  rails

Paul Revere

Build Status

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

Installation

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

Background

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.

Usage

  • 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.

Credits

thoughtbot

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.

License

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].