diff options
Diffstat (limited to 'app/models/chouette/stop_area.rb')
| -rw-r--r-- | app/models/chouette/stop_area.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/chouette/stop_area.rb b/app/models/chouette/stop_area.rb index 1dfdac724..08a5d0826 100644 --- a/app/models/chouette/stop_area.rb +++ b/app/models/chouette/stop_area.rb @@ -40,12 +40,20 @@ module Chouette validates_format_of :url, :with => %r{\Ahttps?:\/\/([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?\Z}, :allow_nil => true, :allow_blank => true validates_numericality_of :waiting_time, greater_than_or_equal_to: 0, only_integer: true, if: :waiting_time + validate :parent_area_type_must_be_greater def self.nullable_attributes [:registration_number, :street_name, :country_code, :fare_code, :nearest_topic_name, :comment, :long_lat_type, :zip_code, :city_name, :url, :time_zone] end + def parent_area_type_must_be_greater + return unless self.parent + if Chouette::AreaType.find(self.area_type) > Chouette::AreaType.find(self.parent.area_type) + errors.add(:parent_id, I18n.t('stop_areas.errors.parent_area_type', area_type: self.parent.area_type)) + end + end + after_update :clean_invalid_access_links before_save :coordinates_to_lat_lng |
