diff options
| author | Robert | 2018-01-09 18:45:26 +0100 |
|---|---|---|
| committer | Robert | 2018-01-09 19:36:28 +0100 |
| commit | 1fd4cb19846151a419216506393ac8ff9bdec2ee (patch) | |
| tree | 6152896e84bf0e26d54d25b1242507e9d5401145 /app | |
| parent | 3e2e0d611d1d3a10df5449e1eb3c1e53bf9bfd2e (diff) | |
| download | chouette-core-1fd4cb19846151a419216506393ac8ff9bdec2ee.tar.bz2 | |
Fixes: #5505@2h; Migrations, specs and implementations
- Migration index_resource_type_on_custom_fields
- Specing behavior of custom field's resource (VehicleJourney)
- Migration create json col custom_field_values for resource (VehicleJourney)
- Create accessor methods inside resource (VehicleJourney)
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/chouette/vehicle_journey.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb index d4dc82a56..89b230d85 100644 --- a/app/models/chouette/vehicle_journey.rb +++ b/app/models/chouette/vehicle_journey.rb @@ -243,6 +243,14 @@ module Chouette end end + def custom_fields + CustomField.where(resource_type: self.class.name.split("::").last) + end + + def custom_field_value key + custom_field_values[key.to_s] + end + def self.matrix(vehicle_journeys) Hash[*VehicleJourneyAtStop.where(vehicle_journey_id: vehicle_journeys.pluck(:id)).map do |vjas| [ "#{vjas.vehicle_journey_id}-#{vjas.stop_point_id}", vjas] |
