Skip to content

Instantly share code, notes, and snippets.

@dsturnbull
Created April 14, 2009 00:44
Show Gist options
  • Save dsturnbull/94861 to your computer and use it in GitHub Desktop.
Save dsturnbull/94861 to your computer and use it in GitHub Desktop.
def method_missing(method, *args)
if method.to_s =~ /^flash_(.*)/
type = case $1
when 'error'
:errors
when 'warning'
:warning
when 'notice'
:notices
end
flash(args.first, type)
else
super(method, *args)
end
end
def flash(m, type)
session[type] ||= []
session[type] += m.errors
end
def flash_messages
out = session.inspect
session.delete(:errors)
session.delete(:warning)
session.delete(:notices)
out
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment