favoritescontroller#destroy should work even if the post doesn't exist, remove from favorites on expunge (fixes #3222)

This commit is contained in:
r888888888
2017-07-19 13:22:24 -07:00
parent 5d013f9c88
commit d48ed95191
7 changed files with 50 additions and 21 deletions

View File

@@ -289,12 +289,12 @@ class User < ApplicationRecord
end
def add_favorite!(post)
Favorite.add(post, self)
Favorite.add(post: post, user: self)
clean_favorite_count! if clean_favorite_count?
end
def remove_favorite!(post)
Favorite.remove(post, self)
Favorite.remove(post: post, user: self)
end
def favorite_groups