修正连续点击喜欢按钮显示不正确的问题

This commit is contained in:
yafeilee 2014-03-31 12:30:36 +08:00
parent bbb3f213f9
commit 5965a8d52f
2 changed files with 4 additions and 3 deletions

View File

@ -20,7 +20,8 @@
$scope.count = res.count
$scope.cancel = ->
$http.delete url + "/" + $scope.like, (res)->
$http.delete url + "/" + $scope.like
.success (res)->
$scope.count = res.count
# anyway, clear cookie
delete $cookies["like"]

View File

@ -21,9 +21,9 @@ class LikesController < ApplicationController
post = Post.find( params[:blog_id] )
like = post.likes.find(params[:id])
if like.destroy
render :json=> { success: true, count: post.liked_count }
render :json=> { success: true, count: post.reload.liked_count }
else
render :json=> { success: false, count: post.liked_count }
render :json=> { success: false, count: post.reload.liked_count }
end
end
end