-total = Notification.pending.for(authenticated(User)).exclude_message.count -notifications = Notification.for(authenticated(User)).exclude_message.order(:read_date,Sequel.desc(:id)).limit(5).all li.dropdown.hidden-xs a.notifications-menu data-toggle="dropdown" href="" i.tm-icon.zmdi.zmdi-notifications -unless total == 0 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(); } }); }