Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Unify the flash message retrieval across views and layouts

  • Loading branch information...
commit 27e162fca57c0d434ce10f68714b0d90bf3e39e3 1 parent 2baa11b
@gregbell gregbell authored
View
4 app/views/layouts/active_admin_logged_out.html.erb
@@ -18,8 +18,8 @@
<div id="wrapper">
<div id="content_wrapper">
- <% if flash.keys.any? %>
- <% flash.each do |type, message| %>
+ <% if active_admin_flash_messages.any? %>
+ <% active_admin_flash_messages.each do |type, message| %>
<%= content_tag :div, message, :class => "flash flash_#{type}" %>
<% end %>
<% end %>
View
1  lib/active_admin/view_helpers.rb
@@ -15,6 +15,7 @@ module ViewHelpers
include FormHelper
include TitleHelper
include ViewFactoryHelper
+ include FlashHelper
end
end
View
13 lib/active_admin/view_helpers/flash_helper.rb
@@ -0,0 +1,13 @@
+module ActiveAdmin
+ module ViewHelpers
+ module FlashHelper
+
+ # Returns all the flash keys to display in any Active Admin view.
+ # This method removes the :timedout key that Devise uses by default
+ def active_admin_flash_messages
+ @active_admin_flash_messages ||= flash.to_hash.except(:timedout)
+ end
+
+ end
+ end
+end
View
6 lib/active_admin/views/pages/base.rb
@@ -63,10 +63,10 @@ def build_page_content
end
def build_flash_messages
- if flash.keys.except(:timedout).any?
+ if active_admin_flash_messages.any?
div :class => 'flashes' do
- flash.keys.except(:timedout).each do |k|
- div flash[k], :class => "flash flash_#{k}"
+ active_admin_flash_messages.each do |type, message|
+ div message, :class => "flash flash_#{type}"
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.