Skip to content
Snippets Groups Projects
Unverified Commit 89e1974f authored by trwnh's avatar trwnh Committed by GitHub
Browse files

Make account endorsements idempotent (fix #19045) (#20118)


* Make account endorsements idempotent (fix #19045)

* Accept suggestion to use exists? instead of find_by + nil check

Co-authored-by: default avatarYamagishi Kazutoshi <ykzts@desire.sh>

* fix logic (unless, not if)

* switch to using `find_or_create_by!`

Co-authored-by: default avatarYamagishi Kazutoshi <ykzts@desire.sh>
parent 455a7540
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ class Api::V1::Accounts::PinsController < Api::BaseController
before_action :set_account
def create
AccountPin.create!(account: current_account, target_account: @account)
AccountPin.find_or_create_by!(account: current_account, target_account: @account)
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships_presenter
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment