Skip to content

Commit

Permalink
Merge pull request #1267 from DigitalCurationCentre/development
Browse files Browse the repository at this point in the history
Fix for duplicate answer issue
  • Loading branch information
briri authored Mar 9, 2018
2 parents e1fef01 + f1ee8ed commit 5082ec3
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def create
# ensure user has access to plan BEFORE creating/finding answer
raise Pundit::NotAuthorizedError unless Plan.find(params[:note][:plan_id]).readable_by?(@note.user_id)
Answer.transaction do
if params[:note][:answer_id].present?
@answer = Answer.find(params[:note][:answer_id])
end
@answer = Answer.find_by(plan_id: params[:note][:plan_id], question_id: params[:note][:question_id])
if @answer.blank?
@answer = Answer.new
@answer.plan_id = params[:note][:plan_id]
Expand Down

0 comments on commit 5082ec3

Please sign in to comment.