-
Notifications
You must be signed in to change notification settings - Fork 5
Make NCES ID mandatory for US schools #638
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
980647f
27313f4
a791df2
37847a1
9313869
0798d34
0559048
b54866d
508b66f
dae0327
e953dd7
aba460d
6877786
f059d13
bef5de5
023a0bd
581db1d
778280a
1785e13
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 |
|---|---|---|
|
|
@@ -558,6 +558,7 @@ GEM | |
| PLATFORMS | ||
| aarch64-linux | ||
| arm64-darwin-24 | ||
| arm64-darwin-25 | ||
| x86_64-linux | ||
|
|
||
| DEPENDENCIES | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,12 +16,21 @@ class School < ApplicationRecord | |||||
| validates :address_line_1, presence: true | ||||||
| validates :municipality, presence: true | ||||||
| validates :country_code, presence: true, inclusion: { in: ISO3166::Country.codes } | ||||||
| validates :reference, uniqueness: { case_sensitive: false, allow_nil: true }, presence: false | ||||||
| validates :district_nces_id, uniqueness: { case_sensitive: false, allow_nil: true }, presence: false | ||||||
| validates :reference, | ||||||
| uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_blank: true, message: I18n.t('validations.school.reference_urn_exists') }, | ||||||
| format: { with: /\A\d{5,6}\z/, allow_nil: true, message: I18n.t('validations.school.reference') }, | ||||||
| if: :united_kingdom? | ||||||
| validates :district_nces_id, | ||||||
| uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_blank: true, message: I18n.t('validations.school.district_nces_id_exists') }, | ||||||
|
||||||
| uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_blank: true, message: I18n.t('validations.school.district_nces_id_exists') }, | |
| uniqueness: { conditions: -> { where(rejected_at: nil) }, case_sensitive: false, allow_nil: true, message: I18n.t('validations.school.district_nces_id_exists') }, |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -15,7 +15,12 @@ en: | |||||
| validations: | ||||||
| school: | ||||||
| website: "must be a valid URL" | ||||||
| reference: "must be 5-6 digits (e.g., 100000)" | ||||||
| reference_urn_exists: "URN number already exists" | ||||||
|
||||||
| reference_urn_exists: "URN number already exists" | |
| reference_urn_exists: "URN has already been taken" |
Copilot
AI
Jan 6, 2026
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.
The custom uniqueness error message "NCES ID already exists" is inconsistent with the standard Rails error messages. According to the PR description's API Error Responses table, the uniqueness error should be "has already been taken" to match Rails conventions.
Consider changing this to "has already been taken" for consistency with Rails standards and the documented API response format.
| district_nces_id_exists: "NCES ID already exists" | |
| district_nces_id_exists: "has already been taken" |
Copilot
AI
Jan 6, 2026
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.
The custom uniqueness error message "School roll number already exists" is inconsistent with the standard Rails error messages. According to the PR description's API Error Responses table and Rails conventions, the uniqueness error should be "has already been taken".
Consider changing this to "has already been taken" for consistency with Rails standards.
| school_roll_number_exists: "School roll number already exists" | |
| school_roll_number_exists: "has already been taken" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| class ChangeReferenceAndNcesIdIndexesToPartial < ActiveRecord::Migration[7.2] | ||
| def change | ||
| # Convert reference (UK URN) index to partial index | ||
| # This allows rejected schools to release their URN for reuse | ||
| remove_index :schools, :reference | ||
| add_index :schools, :reference, unique: true, where: 'rejected_at IS NULL' | ||
|
|
||
| # Convert district_nces_id (US NCES ID) index to partial index | ||
| # This allows rejected schools to release their NCES ID for reuse | ||
| remove_index :schools, :district_nces_id | ||
| add_index :schools, :district_nces_id, unique: true, where: 'rejected_at IS NULL' | ||
| end | ||
| end | ||
|
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,15 +17,19 @@ | |
| address_line_1: '123 Main St', | ||
| municipality: 'Springfield', | ||
| country_code: 'US', | ||
| owner_email: '[email protected]' | ||
| owner_email: '[email protected]', | ||
| district_name: 'Some District', | ||
| district_nces_id: '010000000001' | ||
| }, | ||
| { | ||
| name: 'Test School 2', | ||
| website: 'https://test2.example.com', | ||
| address_line_1: '456 Oak Ave', | ||
| municipality: 'Boston', | ||
| country_code: 'US', | ||
| owner_email: '[email protected]' | ||
| owner_email: '[email protected]', | ||
| district_name: 'Other District', | ||
| district_nces_id: '010000000002' | ||
| } | ||
| ] | ||
| end | ||
|
|
@@ -124,7 +128,9 @@ | |
| 'address_line_1' => '123 Main St', | ||
| 'municipality' => 'Springfield', | ||
| 'country_code' => 'us', | ||
| 'owner_email' => '[email protected]' | ||
| 'owner_email' => '[email protected]', | ||
| 'district_name' => 'Some District', | ||
| 'district_nces_id' => '010000000001' | ||
| } | ||
| ] | ||
| end | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.