icps

notes

Bootstrap_notify

https://github.com/jclay/bootstrap-notify-gem

gem 'bootstrap_notify'

#application.js
//= require jquery
//= require jquery_ujs
//= require bootstrap_notify
#application.scss
@import "bootstrap";
@import "bootstrap_notify";
1
2
3
4
5
6
7
8
9
10
11
12
#app/views/partials/_notify.erb
<% if !notice.blank? %>
  <script> 
      $(document).ready(function () {
          $('.top-left').notify({
              <% flash.each do |name, msg| %>
                  message: { text: "<%= msg %>" }
              <% end %>  
          }).show();
      });
  </script>
<% end %>
1
2
#app/views/layouts/application.erb in head tag
<%= render(:partial => "partials/notify") %>
1
2
#app/views/layouts/application.erb in body tag
#<div class='notifications top-left'></div>
1
2
#app/controllers/uploads_controller.rb
flash[:notice] = "uploaded"