Commit 1850e7582cbb980cb409d5bc15a6e6eda133b14d
Committed by
Rafael Martins
1 parent
83607363
Exists in
master
and in
29 other branches
[geolocalization]
Fix to validate city hierarchy per countries
Showing
1 changed file
with
6 additions
and
1 deletions
Show diff stats
app/models/national_region.rb
| ... | ... | @@ -15,6 +15,7 @@ class NationalRegion < ActiveRecord::Base |
| 15 | 15 | adtional_contions = " AND nr.name = :state " |
| 16 | 16 | end |
| 17 | 17 | |
| 18 | + | |
| 18 | 19 | conditions = ["national_regions.name #{operator} :name AND |
| 19 | 20 | national_regions.national_region_type_id = :type" + adtional_contions, |
| 20 | 21 | {:name => city_name , |
| ... | ... | @@ -54,7 +55,11 @@ class NationalRegion < ActiveRecord::Base |
| 54 | 55 | |
| 55 | 56 | def self.validate!(city, state, country) |
| 56 | 57 | |
| 57 | - if(country == "BR") | |
| 58 | + coutry_region = NationalRegion.find_by_national_region_code(country, | |
| 59 | + :conditions => ["national_region_type_id = :type", | |
| 60 | + {:type => NationalRegionType::COUNTRY}]) | |
| 61 | + | |
| 62 | + if(coutry_region) | |
| 58 | 63 | |
| 59 | 64 | nregion = NationalRegion.search_city(city, false, state); |
| 60 | 65 | ... | ... |