Fix #5208: The posts version of create or update artist commentary endpoint does not work without the post ID parameter being passed in the body

Fix /posts/:post_id/artist_commentary/create_or_update not working
without passing `artist_commentary[post_id]` in the form body.
This commit is contained in:
evazion
2022-08-25 21:50:33 -05:00
parent 91b3a4c37a
commit 18c949ff34
3 changed files with 16 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ class ArtistCommentariesController < ApplicationController
end
def create_or_update
post_id = params[:artist_commentary].delete(:post_id)
post_id = params[:artist_commentary].delete(:post_id) || params[:post_id]
@artist_commentary = authorize ArtistCommentary.find_or_initialize_by(post_id: post_id)
@artist_commentary.update(permitted_attributes(@artist_commentary))
respond_with(@artist_commentary)