aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/lines_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/lines_controller.rb')
-rw-r--r--app/controllers/lines_controller.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/controllers/lines_controller.rb b/app/controllers/lines_controller.rb
index e85c29fc9..0699b0047 100644
--- a/app/controllers/lines_controller.rb
+++ b/app/controllers/lines_controller.rb
@@ -20,8 +20,25 @@ class LinesController < ChouetteController
respond_with(objects, :location => smart_collection_url)
end
+ def name_filter
+ respond_to do |format|
+ format.json { render :json => filtered_lines_maps}
+ end
+
+ end
+
protected
+ def filtered_lines_maps
+ filtered_lines.collect do |line|
+ { :id => line.id, :name => line.published_name }
+ end
+ end
+
+ def filtered_lines
+ referential.lines.select{ |t| t.published_name =~ /#{params[:q]}/i }
+ end
+
def collection
@q = referential.lines.search(params[:q])
@lines ||= @q.result(:distinct => true).order(:number).paginate(:page => params[:page]).includes([:network, :company])