views:

1241

answers:

5

I am about to code something for a Rails app of mine and didn't want to reinvent the wheel, hence my question:

Do you guys know any Rails Plugin that would allow an application to display notification messages that could be user specific and also allow the user to mark them as "don't show this again"?

My vision is to display a top div (like the one StackOverflow added recently), in different color with the message "title" and that would be clickable. Once clicked, it would pop up the entire message and then allow the user to mark it to prevent it to be shown again.

Is there anything like that out there? :-)

I found so far this two plugins:

But those are rather incomplete parts of my vision

-- Felipe.

+1  A: 

Is there a reason why you just don't use the rails built in flash? Then just have some js that hides the flash message when close is clicked?

MatthewFord
A: 

There's already a message notification system built into Rails, which is the flash. When and to whom it appears and what it looks like are application-dependent; as such, it is unlikely that there's a plug-in pre-written that does exactly what you want.

If I were you, I'd assign to the flash in the controller and create a div in the layout that conditionally appears if there's a flash message to communicate. Style with CSS and garnish with JavaScript effects.

Raphomet
+1  A: 

Since I don't have enough reputation to comment - Flash isn't sufficient for a few different reasons:

  1. you're mixing view and controller code. I need to notify users, including URLs and messages that just don't belong in the controller. I can write wrapper functions to do this in views, but it's hacky.
  2. Async notification. If you're using a queue design pattern, you really need a message queue to go along with it, and show the user messages totally independent of the controller they are viewing.
  3. Hard to set state. Some messages should only be displayed to the user once. Need to create a whole message model to track what they clicked and disabled anyway.

I'm also looking for some good solution, and so far the best I can come up with is RYO. I'll ultimately stuff the display code into flash, but figuring out what and when to flash is the trick.

teich
A: 

I use jGrowl (demo), and I'm happy with it. I read about Roar this morning, and I'll be trying that out as well. If you're using MooTools, there's also Window.Growl.

Chris Doggett
+1  A: 

It seems like system_messages (which you linked to) mostly does what you want. The SystemMessage model has header, message, and dismissed fields.

It would take just a bit of JavaScript to show an intially hidden message field when the header is clicked. The plugin already allows dismissal of the message via JavaScript if you use Prototype.

Baldu