diff options
| author | Marc Florisson | 2012-04-23 14:48:17 +0200 |
|---|---|---|
| committer | Marc Florisson | 2012-04-23 14:48:17 +0200 |
| commit | 53cb5d9db1f3ccde220124e75dc04c91bd1802a3 (patch) | |
| tree | 1b75fd017bd401eb5e497e22f261d24c68026189 /app/controllers | |
| parent | ce3a470816e9b58a96ad23acaca87a581f507061 (diff) | |
| download | chouette-core-53cb5d9db1f3ccde220124e75dc04c91bd1802a3.tar.bz2 | |
add route views
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/routes_controller.rb | 30 |
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 + |
