Commit c96909d

mo <mo.khan@gmail.com>
2018-09-01 23:29:03
display flash error messages.
1 parent 1a74253
Changed files (3)
app/helpers/application_helper.rb
@@ -1,4 +1,16 @@
 # frozen_string_literal: true
 
 module ApplicationHelper
+  def alert_class_for(type)
+    case type.to_sym
+    when :notice
+      'alert-success'
+    when :warning
+      'alert-warning'
+    when :error
+      'alert-danger'
+    else
+      'alert-primary'
+    end
+  end
 end
app/views/application/_flash.html.erb
@@ -0,0 +1,7 @@
+<div class="container">
+  <% flash.each do |type, message| %>
+    <% Array(message).each do |value| %>
+      <div class="alert <%= alert_class_for(type) %>" role=alert><%= value %></div>
+    <% end %>
+  <% end %>
+</div>
app/views/layouts/application.html.erb
@@ -10,6 +10,7 @@
     <%= stylesheet_pack_tag 'vendor' %>
   </head>
   <body>
+    <%= render partial: 'flash' %>
     <%= yield %>
   </body>
 </html>