Fix #5146: Adding an existing favorite to favorite groups leads to an error.

Show "Favgroup already contains post XXX" error when trying to add a
post to a favgroup that already contains that post.
This commit is contained in:
evazion
2022-05-02 14:15:53 -05:00
parent 5e923e266b
commit 93352b318e
6 changed files with 26 additions and 17 deletions

View File

@@ -55,6 +55,8 @@ class FavoriteGroupsController < ApplicationController
def add_post
@favorite_group = authorize FavoriteGroup.find(params[:id])
@post = Post.find(params[:post_id])
@favorite_group.add!(@post)
@favorite_group.add(@post)
respond_with(@favorite_group)
end
end