RailsCasts Pro episodes are now free!

Learn more or hide this

drewsheneman's Profile

GitHub User: drewsheneman

Site: http://blog.drewsheneman.com/

Comments by

Avatar

Another great cast.

Caching the comments count only seems to work with a page reload. I am using ajax to add comments and updating the count in create.js.erb: $('#comments_count').html('<%= @article.comments.size %>'); ... when using the cached version the value is not yet updated at this point?

Avatar

I did:

app.factory "Entry", ["$resource", ($resource) ->
  $resource("/entries/:id", {id: "@id"}, {update: {method: "PUT"}, destroy: { method: 'DELETE' }})
]

Then pass in the $index parameter when delete function is called:

<a ng-click="deleteEntry($index)">delete</a>

delete function:

$scope.deleteEntry = (arrayIndex) ->
  entry_to_be_deleted = $scope.entries[arrayIndex]
  Entry.remove({id: entry_to_be_deleted.id})
  $scope.entries.splice arrayIndex, 1