aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette
diff options
context:
space:
mode:
authorTeddy Wing2017-07-18 12:17:10 +0200
committerTeddy Wing2017-07-21 15:59:53 +0200
commit766e6a2a1617d5dee1e31a566421ac74087297b9 (patch)
treee60dc68d6ef5ddb7d925bcafd4479ca9e5a68e26 /app/models/chouette
parentdca839c6b1d55413d613a02ad8e8d98b688b3155 (diff)
downloadchouette-core-766e6a2a1617d5dee1e31a566421ac74087297b9.tar.bz2
VehicleJourneyAtStop: Remove "nested" #error_message method
Robert adeptly pointed out that my `#error_message` method is not a nested method, like I had thought, à la Python. Instead, it actually defines the `#error_message` method on the class at runtime (https://stackoverflow.com/questions/4864191/is-it-possible-to-have-methods-inside-methods/4865161#4865161), so `#error_message` becomes a normal instance method after `#day_offset_must_be_within_range` is called. I did not know this, and that's certainly not what I was going for. Convert the method to a lambda to put it in the local scope. Refs #3597
Diffstat (limited to 'app/models/chouette')
-rw-r--r--app/models/chouette/vehicle_journey_at_stop.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/chouette/vehicle_journey_at_stop.rb b/app/models/chouette/vehicle_journey_at_stop.rb
index 1cb1c4767..3e83eb41a 100644
--- a/app/models/chouette/vehicle_journey_at_stop.rb
+++ b/app/models/chouette/vehicle_journey_at_stop.rb
@@ -35,7 +35,7 @@ module Chouette
end
def day_offset_must_be_within_range
- def error_message
+ error_message = lambda do
I18n.t(
'vehicle_journey_at_stops.errors.day_offset_must_not_exceed_max',
local_id: vehicle_journey.objectid.local_id,