aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorTeddy Wing2017-07-17 17:59:34 +0200
committerTeddy Wing2017-07-21 15:59:53 +0200
commit161f3184783ba3419238d3ce6b2291ef9fabfa01 (patch)
treedc7e42217b3b4052fc98331568316d4e0543abdd /app
parentac03cfc3b24c49b952a31f84cf7063a9cd68acc4 (diff)
downloadchouette-core-161f3184783ba3419238d3ce6b2291ef9fabfa01.tar.bz2
VehicleJourneyAtStop: Add error message to max day offset error
Add a custom error message for when the day offset exceeds our maximum. Unfortunately, this uses Rails 5 lambda syntax, so it doesn't work. Will need to extract it to a method, but figured I'd just commit this anyway for posterity. The French error message text was taken from the Redmine issue, authored by Luc. I translated it into English. Refs #3597
Diffstat (limited to 'app')
-rw-r--r--app/models/chouette/vehicle_journey_at_stop.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb
index c569e5849..f58773d18 100644
--- a/app/models/chouette/vehicle_journey_at_stop.rb
+++ b/app/models/chouette/vehicle_journey_at_stop.rb
@@ -28,11 +28,26 @@ module Chouette
validates :arrival_day_offset, numericality: {
greater_than_or_equal_to: 0,
- less_than_or_equal_to: DAY_OFFSET_MAX
+ less_than_or_equal_to: DAY_OFFSET_MAX,
+ message: ->(object, data) do
+ byebug
+ I18n.t(
+ 'vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max',
+ local_id: object.vehicle_journey.objectid.local_id,
+ max: DAY_OFFSET_MAX + 1
+ )
+ end
}
validates :departure_day_offset, numericality: {
greater_than_or_equal_to: 0,
- less_than_or_equal_to: DAY_OFFSET_MAX
+ less_than_or_equal_to: DAY_OFFSET_MAX,
+ message: ->(object, data) do
+ I18n.t(
+ 'vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max',
+ local_id: object.vehicle_journey.objectid.local_id,
+ max: DAY_OFFSET_MAX + 1
+ )
+ end
}
after_initialize :set_virtual_attributes