Skip to content

Instantly share code, notes, and snippets.

@dolzenko
Created August 17, 2010 17:03
Show Gist options
  • Save dolzenko/530859 to your computer and use it in GitHub Desktop.
Save dolzenko/530859 to your computer and use it in GitHub Desktop.
module Responders
module FlashResponder
protected
def set_flash_message!
# Make FlashResponder set :alert flash on failed destroy action
if has_errors? || (delete? && !resource.destroyed?)
set_flash(:alert, @alert)
status = Responders::FlashResponder.flash_keys.last
else
set_flash(:notice, @notice)
status = Responders::FlashResponder.flash_keys.first
end
return if controller.flash[status].present?
options = mount_i18n_options(status)
message = ::I18n.t options[:default].shift, options
set_flash(status, message)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment