blob: af041c33e6980a8303d52863cb8e70405abdc1c8 (
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 < ChouetteController
  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
 |