Commit c96909d
Changed files (3)
app
helpers
views
application
layouts
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>