Skip to content

Commit

Permalink
Merge pull request #10 from naoki1510/develop
Browse files Browse the repository at this point in the history
削除時の問題番号の不一致を解消
  • Loading branch information
naoki1510 authored Mar 12, 2024
2 parents 2b4e147 + 498d24d commit 64d8cbf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/app/models/question.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion client/src/components/users/ListUsers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default memo(function ListUsers() {

//createObjectURLで作成したオブジェクトURLを開放する
URL.revokeObjectURL(link.href);
}, []);
}, [users]);

return (
<VStack align={"stretch"} flex={1} gap={4}>
Expand Down

0 comments on commit 64d8cbf

Please sign in to comment.