-total = Notification.pending.for(authenticated(User)).count -notifications = Notification.pending.for(authenticated(User)).order(Sequel.desc(:id)).limit(20).all

li.dropdown.hidden-xs

-if total == 0
  a href="/notifications" title="No tienes notificaciones pendientes"
    i.tm-icon.zmdi.zmdi-notifications-none
-else
  a.notifications-menu data-toggle="dropdown" href="" 
    i.tm-icon.zmdi.zmdi-notifications
    i.notification-count.tmn-counts.animated.bounceIn #{total}
.dropdown-menu.dropdown-menu-lg.pull-right
  .listview
    .lv-header
      | Notificaciones
      ul.actions
        li.dropdown
          -unless total == 0
            a data-clear="notification" role="button" onclick="read_all_notifications(#{{Notification.pending.for(authenticated(User)).exclude_message.all.collect { |notification| notification.id}}});this.onclick='';" 
              i.zmdi.zmdi-check-all
    .lv-body#notifications-list
      -for notification in notifications
        == slim :'sinatra-hexacta/notifications/item', locals: { :notification => notification }
    a.lv-footer href="/notifications" Ver todas

javascript:

function read_all_notifications(ids) {
  $.ajax({
    url: '/notifications',
    type: 'POST',
    data: { ids : ids },
    success: function(result) {
      location.reload();
    }
  });
}