diff --git a/api/app/models/question.rb b/api/app/models/question.rb index 32270e5..b7f898f 100644 --- a/api/app/models/question.rb +++ b/api/app/models/question.rb @@ -4,6 +4,7 @@ class Question < ApplicationRecord has_many :users, through: :answers before_save :set_display_order + after_destroy :reduce_display_order scope :ordered, -> { order(display_order: :asc) } scope :active, -> { where("started_at <= ? AND ? < ended_at", Time.current, Time.current) } @@ -45,4 +46,8 @@ def set_display_order end end + def reduce_display_order + Question.where("display_order > ?", self.display_order).update_all("display_order = display_order - 1") + end + end \ No newline at end of file diff --git a/client/src/components/users/ListUsers.tsx b/client/src/components/users/ListUsers.tsx index b42cdf6..5417de4 100644 --- a/client/src/components/users/ListUsers.tsx +++ b/client/src/components/users/ListUsers.tsx @@ -34,7 +34,7 @@ export default memo(function ListUsers() { //createObjectURLで作成したオブジェクトURLを開放する URL.revokeObjectURL(link.href); - }, []); + }, [users]); return (