19Aug/091
jGrowl on Rails (with i18n)
Install JQuery and jGrowl plugin.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | def display_flash flash_types = [:error, :warning, :notice] messages = ((flash_types & flash.keys).collect do |key| "$.jGrowl('#{flash[key]}', { header: '#{I18n.t(key, :default => key.to_s)}', theme: '#{key.to_s}'});" end.join("\n")) if messages.size > 0 content_tag(:script, :type => "text/javascript") do "$(document).ready(function() { #{messages} });" end else "" end end |
Related posts:
- i18n URL-based breadcrumbs in Rails
- Reminder: empty email subjects in Snow Leopard server’s postfix
- Rails users < membership > groups? Enter Workflow
- Send SMS with Ruby on Rails
- Rails vs. Tarantula
Enjoy this article?
Additional comments powered by BackType
June 19th, 2010 - 17:06
Nice blog. Thanks for the code – very handy.