aboutsummaryrefslogtreecommitdiffstats
path: root/app/controllers/routes_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/routes_controller.rb')
-rw-r--r--app/controllers/routes_controller.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb
new file mode 100644
index 000000000..958d23cf9
--- /dev/null
+++ b/app/controllers/routes_controller.rb
@@ -0,0 +1,30 @@
+class RoutesController < ChouetteController
+ defaults :resource_class => Chouette::Route
+
+ respond_to :html, :xml, :json
+
+ belongs_to :referential do
+ belongs_to :line, :parent_class => Chouette::Line, :optional => true, :polymorphic => true
+ end
+
+ def index
+ @per_page = 10
+ index!
+ end
+
+ protected
+
+ alias_method :route, :resource
+
+ def collection
+ @q = parent.routes.search(params[:q])
+ @routes ||=
+ begin
+ routes = @q.result(:distinct => true).order(:name)
+ routes = routes.paginate(:page => params[:page], :per_page => @per_page) if @per_page.present?
+ routes
+ end
+ end
+
+end
+