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!”, just like Paul Reveresson said.
Thus we have the paul_revere gem.
To start, toss the gem in your
There is an included generator, so be sure to run it:
rails g paul_revere
This will generate a migration to add an
table, so run that:
We’re almost there. Next up modify your layout to have a place for
<%= render 'announcements/announcement_for_all' %>
//= require announcements
Whew! A simple process that will only become easier with improvements to Rails.
% 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 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 gem today!