Skip to content

Instantly share code, notes, and snippets.

@damien
Created April 15, 2010 19:30
Show Gist options
  • Save damien/367530 to your computer and use it in GitHub Desktop.
Save damien/367530 to your computer and use it in GitHub Desktop.
A simple helper method/view to display flash notices and alerts. The application this code is extracted from utilized José Valim's excellant Responders gem to display localized messages.
%div.alert= flash[:alert]
%div.notice= flash[:notice]
!!!
%html
%head
%title
Scanlatr:
= controller.controller_name.capitalize
= controller.action_name.capitalize
= csrf_meta_tag
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'compiled/print.css', :media => 'print'
/[if lt IE 8]
= stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
= javascript_include_tag :defaults
%body.bp
= render_flash_messages
= yield
module ApplicationHelper
def render_flash_messages
if flash[:notice]
render :partial => 'shared/flash_notice', :object => flash[:notice]
end
if flash[:alert]
render :partial => 'shared/flash_alert', :object => flash[:alert]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment