public
Description: A rails plugin that provides view helpers to display configurable notifications.
Homepage:
Clone URL: git://github.com/jstewart/system_messages.git
jstewart (author)
Tue Jul 01 09:39:23 -0700 2008
commit  5b537bb7dc403fc7a2195d21f4cf0a52b01cf380
tree    94eb25782727871cbd904ddf40a60782e8106eba
parent  bbbf19c62385d01648c4e6722e91b0891bf839c2
name age message
file .gitignore Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
file MIT-LICENSE Tue Jun 03 10:32:46 -0700 2008 Added my name to the MIT license. [jstewart]
file README Tue Jul 01 09:39:23 -0700 2008 Fixed error in README example [jstewart]
file Rakefile Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
directory generators/ Mon Jun 02 14:00:51 -0700 2008 Added rails 2.1 note and made the model a littl... [jstewart]
file init.rb Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
file install.rb Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
directory lib/ Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
directory public/ Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
directory tasks/ Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
directory test/ Tue Jun 03 09:36:16 -0700 2008 Remove tests for now until I can figure out a w... [jstewart]
file uninstall.rb Mon Jun 02 13:54:28 -0700 2008 Initial Import [jstewart]
README
SystemMessages
==============

This plugin displays system messages globally, for a specific object, or for a block.

To generate the necessary model, controller, and migration run the following command:
ruby ./script/generate system_message

To use the plugin, run rake db:migrate to create the SystemMessage model.

The plugin can be used as-is at this point to display global system messages and static system messages.
To set up messages for a specific model, use polymorphic associations:

class User < ActiveRecord::Base
  has_many :system_messages, :as => :messageable
end

To create a global system message, leave messageable_id nil when creating a new SystemMessage.

To link the stylesheet:
<%= stylesheet_link_tag 'system_messages' %>

The message dismissal action uses prototype, so you'll probably want to link in prototype and friends:
<%= javascript_include_tag :defaults %>

If you want to change the default style (and you probably will), edit public/stylesheets/system_message.css. You'll also 
want to create a CRUD interface to add SystemMessage records. By default, there are 3 levels of messages that you can 
specify. error, warn, and info. You can easily add more levels by editing the stylesheet.


NOTE: This plugin only works with Rails 2.1 and up.

Example
=======

To Display global system messages in your view:
<%= system_messages %>

System messages for a specific user (or any other model of your choosing):
<%= system_messages_for(current_user) %>

Displaying a system message for the text of your choosing:
<% static_system_message('info', 'This is my header text') do %>
  Blah, Blab, blah
<% end %>

All 3 helpers accept an options hash as the last parameter. If you need to add non-default attributes to
the div (such as overriding the class or id), pass them in as the last argument to the helper.

<%= system_messages(:class => 'foo', :id => 'bar') %>


Copyright (c) 2008 Jason Stewart, released under the MIT license