fixes #2731: Expunged posts should clear favorite groups

This commit is contained in:
Albert Yi
2016-11-01 13:44:36 -07:00
parent cb1c694074
commit 91793fff82
4 changed files with 92 additions and 0 deletions

View File

@@ -18,6 +18,11 @@ class FavoriteGroup < ActiveRecord::Base
where("favorite_groups.creator_id = ?", user_id)
end
def for_post(post_id)
regexp = "(^#{post_id}$|^#{post_id} | #{post_id}$| #{post_id} )"
where("favorite_groups.post_ids ~ ?", regexp)
end
def named(name)
where("lower(name) = ?", name.to_s.mb_chars.downcase.strip)
end