app/views/users/notifications/index.js.erb
<%
# Render notifications
notifications = @notifications.map do |notification|
render 'notification', notification: notification
end
html = safe_join(notifications, "\n")
%>
// Update list
var html = "<%= escape_javascript(html) %>";
$("#notifications-list").html(html);
// Update badge
$("#notifications-badge").text(<%= @notifications.to_a.count { |n| !n.read } %>)