Skip to content

Instantly share code, notes, and snippets.

@coderberry
Created January 12, 2010 21:52
Show Gist options
  • Select an option

  • Save coderberry/275662 to your computer and use it in GitHub Desktop.

Select an option

Save coderberry/275662 to your computer and use it in GitHub Desktop.
# Create the plugin
./script/generate plugin flash_helper
# init.rb
require File.dirname(__FILE__) + '/lib/flash_helper'
ActionView::Base.send(:include, FlashHelper)
# flash_helper.rb
module FlashHelper
def display_flash(flash)
ret = []
flash.each do |key, value|
ret << content_tag(:div, value, :id => "flash_#{key}")
end
return ret.join("\n")
end
end
# application.html.erb
<%= display_flash(flash) %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment