       @navigate "sensors/#{sensor.id}", { trigger: true }
 
   # Ensure the API Key is displayed in the URL params.
-  addApiKeyParam: ->
+  addApiKeyParam: (base) ->
     if (location.search.length < 1)
-      @navigate "sensors?api_key=#{@apiKey}", { replace: true }
+      @navigate "#{base}?api_key=#{@apiKey}", { replace: true }
 
   cleanupViews: ->
     if @indexView

  show: (id) ->
    console.log "loading show route", id
    @cleanupViews()

    if id is "demo"
      # Demo user

      params = $.deparam(location.search.split('?')[1])
      @apiKey ||= params.api_key

  # ROUTES

  index: ->
    console.log "loading index route"
    @cleanupViews()
    @addApiKeyParam("sensors")

    sensors = new Workbench.Collections.SensorsCollection
      source: Workbench.source
