From 84ebcffb06d9ba9a56cc29d1739f1f950649f82e Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Mon, 19 Jun 2017 15:31:19 +0200 Subject: Routes#show: Use RouteDecorator#action_links to render header links Instead of defining the header links in the view, get them from our decorator so we can reuse them. Need to wrap `@route` in the decorator in the controller and pass it the necessary context in order for it to be able to properly build links. Move `Chouette::RouteDecorator` to the top level app/decorators/ directory and remove it from the `Chouette` namespace. I had put it there to make it more similar to our model directory layout, but Draper isn't intelligent enough to look in subdirectories of `decorators` when using the `ActiveRecord::Base#decorate` method. Otherwise I suppose I could do `Chouette::RouteDecorator.decorate(@route)`, but that seemed not as clean since it doesn't take advantage of the default behaviour of Draper. Now going to have to do this for the other decorators. Refs #3479 --- app/controllers/routes_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/controllers/routes_controller.rb') diff --git a/app/controllers/routes_controller.rb b/app/controllers/routes_controller.rb index 73febc4b9..786bd57cc 100644 --- a/app/controllers/routes_controller.rb +++ b/app/controllers/routes_controller.rb @@ -42,6 +42,12 @@ class RoutesController < ChouetteController end show! do + @route = @route.decorate(context: { + referential: @referential, + line: @line, + route_sp: @route_sp + }) + build_breadcrumb :show end end -- cgit v1.2.3