Giter VIP home page Giter VIP logo

paul_revere's Introduction

Paul Revere

Build Status

Simple announcement plugin to include "one off" style announcements in Rails web apps.

Paul Revere's Ride

Install with the asset pipeline (Rails 3.1+, asset pipeline enabled)

Install as normal in your Gemfile:

gem 'paul_revere'

Run the generator to create the migration:

rails generate paul_revere

Add the announcement JS to app/assets/javascripts/application.js:

//= require announcements

Run the migration:

rake db:migrate && rake db:migrate:redo

Install without the asset pipeline (Rails 3.0 or asset pipeline disabled)

Install as normal in your Gemfile:

gem 'paul_revere'

Run the generator to create the migration and copy the JavaScript file into public:

rails generate paul_revere

Add the announcement JS to your layout, such as app/views/layouts/application.html.erb:

<%= javascript_include_tag 'announcements' %>

Run the migration:

rake db:migrate && rake db:migrate:redo

Usage

Paul Revere provides...

  • A model called Announcement, which has nothing more than timestamps and a "body" column (text column). We view the most recent Announcement as the "current" announcement, and will select that to show on the site.
  • A helper called #current_announcement, which will return that latest Announcement record.
  • A view partial called _announcement_for_all, which is intended to be shown to all site users.
  • A view partial called _announcement, which is intended to be shown only to logged in users.
  • A view partial called _email_announcement, which is intended to be used in site emails which are sent out.

So the flow would be...

  • Install the gem

  • Use those partials in the correct places in your view code and mailer view code where you want announcements to show up:

      <%= render 'announcements/announcement_for_all' %>
    
  • When you want to make an announcement, use the Rails console to create a new Announcement record:

      Announcement.create!(body: 'This Web site is shutting down because you refuse to pay')
    

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-2014 thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.

paul_revere's People

Contributors

mjankowski avatar qrush avatar mike-burns avatar cmeiklejohn avatar jferris avatar camdez avatar nickrivadeneira avatar amrit avatar r00k avatar sikachu avatar

Watchers

Chris Williams avatar

Forkers

digideskio

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.