blob: 4922e214c0b143dd29765e23a3def7d1020af895 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 | class AutocompleteTimebandsController < InheritedResources::Base
  respond_to :json, :only => [:index]
  include ReferentialSupport
  protected
  def select_timebands
    if params[:route_id]
      referential.timebands.joins( vehicle_journeys: :route).where( "routes.id IN (#{params[:route_id]})")
    else
      referential.timebands
    end
  end
  def referential_timebands
    @referential_timebands ||= select_timebands
  end
  def collection
    @timebands = referential_timebands.select{ |p| p.fullname =~ /#{params[:q]}/i  }
  end
end
 |