Commit 7d29b6c

mo <mo.khan@gmail.com>
2018-09-02 15:22:07
allow flash messages to be dismissed.
1 parent 55e15bf
Changed files (2)
app
app/helpers/application_helper.rb
@@ -13,4 +13,17 @@ module ApplicationHelper
       'alert-primary'
     end
   end
+
+  def alert_message_for(type)
+    case type.to_sym
+    when :notice
+      'Hot dog!'
+    when :warning
+      'Holy guacamole!'
+    when :error
+      'Danger Will Robinson!'
+    else
+      '🤷'
+    end
+  end
 end
app/views/application/_flash.html.erb
@@ -1,7 +1,12 @@
 <div class="container">
   <% flash.each do |type, message| %>
     <% Array(message).each do |value| %>
-      <div class="alert <%= alert_class_for(type) %>" role=alert><%= value %></div>
+      <div class="alert <%= alert_class_for(type) %> alert-dismissible fade show" role="alert">
+        <strong><%= alert_message_for(type) %></strong> <%= value %>
+        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
+          <span aria-hidden="true">&times;</span>
+        </button>
+      </div>
     <% end %>
   <% end %>
 </div>