aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-02-01 12:31:52 +0100
committerTeddy Wing2018-02-01 15:42:04 +0100
commitf7317ff7a1e5cba9bec9a3ab5571699938924c57 (patch)
tree4c12ab5459160b07f37992d9cfe32c2dfd0fbb79
parent87ca2f0e7fd9b331363eb3f2dc4ba891f8a1901a (diff)
downloadchouette-core-f7317ff7a1e5cba9bec9a3ab5571699938924c57.tar.bz2
ReferentialVehicleJourneys#index: Use ransack filter for line id
I went with this custom filter because I couldn't get it to work with a symbol-based filter in the template. But Johan suggested trying it and I guess it works. Not sure what I was doing that didn't work before. Refs #5576
-rw-r--r--app/controllers/referential_vehicle_journeys_controller.rb1
-rw-r--r--app/models/chouette/vehicle_journey.rb5
-rw-r--r--app/views/referential_vehicle_journeys/_filters.html.slim2
3 files changed, 1 insertions, 7 deletions
diff --git a/app/controllers/referential_vehicle_journeys_controller.rb b/app/controllers/referential_vehicle_journeys_controller.rb
index 935b52d93..2ce28a5cc 100644
--- a/app/controllers/referential_vehicle_journeys_controller.rb
+++ b/app/controllers/referential_vehicle_journeys_controller.rb
@@ -16,7 +16,6 @@ class ReferentialVehicleJourneysController < ChouetteController
def collection
@q ||= end_of_association_chain
- @q = @q.with_line_id(params[:q][:line_id]) if params[:q] && params[:q][:line_id]
@q = @q.with_stop_area_ids(params[:q][:stop_area_ids]) if params[:q] && params[:q][:stop_area_ids]
@q = ransack_period_range(scope: @q, error_message: t('vehicle_journeys.errors.purchase_window'), query: :in_purchase_window, prefix: :purchase_window)
@q = ransack_period_range(scope: @q, error_message: t('vehicle_journeys.errors.time_table'), query: :with_matching_timetable, prefix: :time_table)
diff --git a/app/models/chouette/vehicle_journey.rb b/app/models/chouette/vehicle_journey.rb
index 918ca07aa..30b8903a1 100644
--- a/app/models/chouette/vehicle_journey.rb
+++ b/app/models/chouette/vehicle_journey.rb
@@ -52,10 +52,6 @@ module Chouette
end
}
- scope :with_line_id, ->(id) {
- joins(:route).where(routes: { line_id: id })
- }
-
scope :in_purchase_window, ->(range){
purchase_windows = Chouette::PurchaseWindow.overlap_dates(range)
sql = purchase_windows.joins(:vehicle_journeys).select('vehicle_journeys.id').uniq.to_sql
@@ -63,7 +59,6 @@ module Chouette
}
# We need this for the ransack object in the filters
- ransacker :line_id
ransacker :purchase_window_date_gt
ransacker :stop_area_ids
diff --git a/app/views/referential_vehicle_journeys/_filters.html.slim b/app/views/referential_vehicle_journeys/_filters.html.slim
index 53084017b..67bb60e8d 100644
--- a/app/views/referential_vehicle_journeys/_filters.html.slim
+++ b/app/views/referential_vehicle_journeys/_filters.html.slim
@@ -21,7 +21,7 @@
required: false,
class: 'control-label'
.form-inline.filter_menu
- = f.input :line_id,
+ = f.input :route_line_id_eq,
as: :select,
collection: @vehicle_journeys.lines,
selected: params[:q] && params[:q][:line_id],