   ).property('@each.score').cacheable()
   
   # Creation method for adding a new canddiate
-  createCandidate: (name, shouldSave = true, score = 0, id) ->
-    cand = VoteList.Candidate.create name: name, score: score, id: id
+  createCandidate: (displayName, shouldSave = true, score = 0, id) ->
+    console.log displayName
+    cand = VoteList.Candidate.create displayName: displayName, score: score, id: id
+
     this.pushObject(cand)
+
     if (shouldSave)
-      cand.create()
+      cand.save()
 
 
 # View for creating a new candidate


# Basic setup on first page load
jQuery ->
  console.log('ready')

  # Setup common AJAX settings for most requests
  $.ajaxSetup
    type: 'POST'
    headers: 
      'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
    accept: 'application/json'
  
  # Load the candidates to use initially
  $.ajax
    type: 'GET'
    url: 'candidate'
    success: (data) ->
      jQuery.each data, (i, elem) ->
        VoteList.CandidateController.createCandidate(elem.name, false, elem.score, elem.id)


# Send VoteList out to the rest of the system



# Model object indicating one potential vote recipient
VoteList.Candidate = Ember.Resource.extend
  url: 'candidate'
  name: 'candidate'
  properties: ['displayName', 'score']

  displayName: 'somebody'
  score: 0
  
  # Increment the score by one
  upvote: ->
    this.set 'score', this.get('score') + 1
    this.save()
  
  # Decrement the score by one
  downvote: ->
    this.set 'score', this.get('score') - 1
    this.save()


# Controller for candidate models
VoteList.CandidateController = Ember.ResourceController.create
  type: VoteList.Candidate
  url: 'candidate'

  # Computed property to keep content sorted
  sortedContent:(() ->
