$(function() {
  var lastID
  var count     = 10
  var tableBody = $("table tbody")
  var alertBox  = $(".alert")
  var template  = _.template($("#row-template").html())

  var label_classes = {
    "success": "label-success",
    "pending": "label-info",
    "failure": "label-danger"
  }

  $(document).ajaxError(function(event, jqxhr, settings, error) {
    var msg = settings.type + " " + settings.url + " Error!"

    alertBox.removeClass("hide").find("p").text(msg)
  })

  window.fetch = function() {
    params = { count: count }

    if(typeof(lastID) != "undefined") {
      params.before = lastID
    }

    $.getJSON("/builds", params, function(builds) {
      _.each(builds, function(build) {
	lastID = build.id
	build.created_at = moment(build.created_at)
	build.label_class = label_classes[build.state]
	var row = template(build)
	tableBody.append(row)
      })
    })
  }

  window.fetch()
})

$(function() {
  var lastID
  var count     = 10
  var tableBody = $("table tbody")
  var alertBox  = $(".alert")
  var template  = _.template($("#row-template").html())

  var label_classes = {
    "success": "label-success",
    "pending": "label-info",
    "failure": "label-danger"
  }

  $(document).ajaxError(function(event, jqxhr, settings, error) {
    var msg = settings.type + " " + settings.url + " Error!"

    alertBox.removeClass("hide").find("p").text(msg)
  })

  window.fetch = function() {
    params = { count: count }

    if(typeof(lastID) != "undefined") {
      params.before = lastID
    }

    $.getJSON("/builds/", params, function(builds) {
      _.each(builds, function(build) {
	lastID = build.id
	build.created_at = moment(build.created_at)
	build.label_class = label_classes[build.state]
	var row = template(build)
	tableBody.append(row)
      })
    })
  }

  window.fetch()
})

Fix builds.js