File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525# index_local_authorities_on_nation_and_short_name (nation,short_name)
2626# index_local_authorities_on_short_name (short_name)
2727#
28+
2829class LocalAuthority < ApplicationRecord
2930 self . primary_key = :mhclg_code
3031
3132 validates :mhclg_code , uniqueness : true
3233 validates :gias_code , uniqueness : true , allow_nil : true
3334 validates :gss_code , uniqueness : true , allow_nil : true
3435
35- has_many :postcodes ,
36- foreign_key : :gss_code ,
37- primary_key : :gss_code ,
38- class_name : "LocalAuthority::Postcode"
36+ has_many :postcodes , foreign_key : :gss_code , primary_key : :gss_code
3937
4038 enum :nation ,
4139 {
@@ -80,8 +78,6 @@ def self.from_my_society_import_row(data)
8078 end
8179
8280 def self . for_postcode ( postcode )
83- joins ( :postcodes ) . merge (
84- LocalAuthority ::Postcode . where ( value : postcode )
85- ) . first
81+ joins ( :postcodes ) . merge ( Postcode . where ( value : postcode ) ) . first
8682 end
8783end
Original file line number Diff line number Diff line change 1414# index_local_authority_postcodes_on_gss_code (gss_code)
1515# index_local_authority_postcodes_on_value (value) UNIQUE
1616#
17+
1718class LocalAuthority ::Postcode < ApplicationRecord
18- belongs_to :local_authority ,
19- foreign_key : :gss_code ,
20- primary_key : :gss_code ,
21- optional : true
19+ belongs_to :local_authority , foreign_key : :gss_code , primary_key : :gss_code
2220
2321 normalizes :value ,
2422 with : -> ( given_value ) do
Original file line number Diff line number Diff line change 3131# index_locations_on_urn (urn) UNIQUE WHERE ((type = 0) AND (site IS NULL))
3232# index_locations_on_urn_and_site (urn,site) UNIQUE
3333#
34+
3435class Location < ApplicationRecord
3536 self . inheritance_column = nil
3637
You can’t perform that action at this time.
0 commit comments