Stickes, The Description:
Stickies is a Ruby on Rails plugin that provides a nice interface for displaying messages, similar to what you’re doing now with flash[:notice] or flash[:message], only much better.
Messages created with the Stickies API can act just like the flash based mechanism it aims to replace, that is, they go away after the next page draw. But they can also be told to stick around until the user actually clicks the close link/icon. There are also ways to display a message at regular intervals.
Stickies, The API:
1 2 3 4 5 |
# These methods can be called from your controllers or views notice_stickie("Account activated") error_stickie("Your account has been disabled") warning_stickie("Your account will expire in 3 days") debug_stickie("This only works when RAILS_ENV is development") |
Stickies, The Step By Step:
Step 1: Get the Source Code
svn co http://pmade.com/svn/oss/stickies/trunk vendor/plugins/stickies
Step 2: Add Stickies To Your Rails App
Run the generator to create the CSS file:
./script/generate stickies
Add the CSS file to your layout:
<%= stylesheet_link_tag('stickies') %> |
Render the stickies in your layout (where you show the flash message):
<%= render_stickies %> |
Step 3: Start Creating Stickies
1 2 3 4 5 6 7 8 9 |
# Typical status message notice_stickie("Hey, you look good today!") # Display a browser warning no more often than every 24 hours warning_stickie("Your browser sucks", { :remember => true, :name => :browser_warning, :seen_in => 24.hours, }) |
Step 4: Learn More
Take a look at the README. Also, the source code is clean and well documented.
Updated May 02, 2007 by Peter Jones
Tags:
Comments:
Thanks DeLynn, fixed.
Peter:
I was trying to take a look at your new plugin, but it is not loading properly.
I am going to look into it for a bit and will let you know.
/usr/home/chris/projects/greek/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/module/ali sing.rb:28:in `alias_method': undefined method `call_filter' for class `ActionController::Base' (NameError) from /usr/home/chris/projects/greek/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_e t/module/aliasing.rb:28:in `alias_method_chain' from /usr/home/chris/projects/greek/vendor/plugins/stickies/lib/stickies/controller_actions.rb:32:in `included' from /usr/home/chris/projects/greek/vendor/plugins/stickies/lib/stickies/controller_actions.rb:31:in `included'
-Christopher Wilson
This has been fixed, thanks for the heads up!
Awesome plugin, thanks a lot. I think I'm going to use this somehow to alert the user when they have incoming messages or notifications when they login.
Hi,
I use stickies on my Rails 2.0.2 with default session cookie store. I found stickies can't be removed automatically.
Because cookie has 4K limit, it will occur CookieOverflow very soon if user plays around for a while.
How can I solve this?
I just found messages.flash inside render_stickies of render_helpers.rb that doesn't work. That's why it can't delete all messages automatically and overflow my session cookie.
Any suggestions?
Great plugin.
It would be really nice to have an option to have the stickie close itself after x amount of time instead of making the user click the close button.
Have something to say? Login to post a comment.
DeLynn Berry, May 06, 2007
Level 2 (Lurker with 1 point)
I just finished installing Stickies into an existing project of mine but ran into a problem initially trying to get it to work. There is a dependency on the OpenStruct class, but the plugin never requires it anywhere. I added the require to the init.rb file and now things seem to be working as expected.
Thanks for the great plugin!
— DeLynn Berry http://delynnberry.com