-
Notifications
You must be signed in to change notification settings - Fork 5
Change creator_id to only need to be unique for schools where rejecte… #742
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,7 +31,11 @@ class School < ApplicationRecord | |||||||||||||||||||||||||
| format: { with: /\A[0-9]+[A-Z]+\z/, allow_nil: true, message: I18n.t('validations.school.school_roll_number') }, | ||||||||||||||||||||||||||
| presence: true, | ||||||||||||||||||||||||||
| if: :ireland? | ||||||||||||||||||||||||||
| validates :creator_id, presence: true, uniqueness: true | ||||||||||||||||||||||||||
| validates :creator_id, | ||||||||||||||||||||||||||
| presence: true, | ||||||||||||||||||||||||||
| uniqueness: { | ||||||||||||||||||||||||||
| conditions: -> { where(rejected_at: nil) } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+34
to
+38
|
||||||||||||||||||||||||||
| validates :creator_agree_authority, presence: true, acceptance: true | ||||||||||||||||||||||||||
| validates :creator_agree_terms_and_conditions, presence: true, acceptance: true | ||||||||||||||||||||||||||
| validates :creator_agree_responsible_safeguarding, presence: true, acceptance: true | ||||||||||||||||||||||||||
|
Comment on lines
+36
to
41
|
||||||||||||||||||||||||||
| uniqueness: { | |
| conditions: -> { where(rejected_at: nil) } | |
| } | |
| validates :creator_agree_authority, presence: true, acceptance: true | |
| validates :creator_agree_terms_and_conditions, presence: true, acceptance: true | |
| validates :creator_agree_responsible_safeguarding, presence: true, acceptance: true | |
| uniqueness: true | |
| validates :creator_agree_authority, presence: true, acceptance: true | |
| validates :creator_agree_terms_and_conditions, presence: true, acceptance: true | |
| validates :creator_agree_responsible_safeguarding, presence: true, acceptance: true | |
| validates :creator_agree_terms_and_conditions, presence: true, acceptance: true | |
| validates :creator_agree_responsible_safeguarding, presence: true, acceptance: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allowing multiple schools per creator_id (when prior ones are rejected) makes
School.find_for_user!ambiguous: it currently doesfind_by(creator_id: user.id)without preferring the active (non-rejected) school. This can return an older rejected school, causing/api/my_schoolto surface the wrong record. Consider scoping the lookup torejected_at: nil(or otherwise selecting the most relevant school deterministically).