Skip to content

Commit

Permalink
Only display user-facing flashes
Browse files Browse the repository at this point in the history
We sometimes use the flash for things such as
"sign up" in order to send data to analytics systems
such as Mixpanel.

We've then ended up doing the following on a number of projects.
  • Loading branch information
Dan Croak committed Apr 8, 2015
1 parent 74cb056 commit 6c562b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/suspenders/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def create_partials_directory
end

def create_shared_flashes
copy_file '_flashes.html.erb', 'app/views/application/_flashes.html.erb'
copy_file "_flashes.html.erb", "app/views/application/_flashes.html.erb"
copy_file "flashes_helper.rb", "app/helpers/flashes_helper.rb"
end

def create_shared_javascripts
Expand Down
2 changes: 1 addition & 1 deletion templates/_flashes.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if flash.any? %>
<div id="flash">
<% flash.each do |key, value| -%>
<% user_facing_flashes.each do |key, value| -%>
<div class="flash-<%= key %>"><%= value %></div>
<% end -%>
</div>
Expand Down
5 changes: 5 additions & 0 deletions templates/flashes_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module FlashesHelper
def user_facing_flashes
flash.to_hash.slice("alert", "error", "notice", "success")
end
end

0 comments on commit 6c562b9

Please sign in to comment.