This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 5b537bb7dc403fc7a2195d21f4cf0a52b01cf380
tree 94eb25782727871cbd904ddf40a60782e8106eba
parent bbbf19c62385d01648c4e6722e91b0891bf839c2
tree 94eb25782727871cbd904ddf40a60782e8106eba
parent bbbf19c62385d01648c4e6722e91b0891bf839c2
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Mon Jun 02 13:54:28 -0700 2008 | |
| |
MIT-LICENSE | Tue Jun 03 10:32:46 -0700 2008 | |
| |
README | Tue Jul 01 09:39:23 -0700 2008 | |
| |
Rakefile | Mon Jun 02 13:54:28 -0700 2008 | |
| |
generators/ | Mon Jun 02 14:00:51 -0700 2008 | |
| |
init.rb | Mon Jun 02 13:54:28 -0700 2008 | |
| |
install.rb | Mon Jun 02 13:54:28 -0700 2008 | |
| |
lib/ | Mon Jun 02 13:54:28 -0700 2008 | |
| |
public/ | Mon Jun 02 13:54:28 -0700 2008 | |
| |
tasks/ | Mon Jun 02 13:54:28 -0700 2008 | |
| |
test/ | Tue Jun 03 09:36:16 -0700 2008 | |
| |
uninstall.rb | Mon Jun 02 13:54:28 -0700 2008 |
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







