diff options
| author | Teddy Wing | 2017-06-19 15:31:19 +0200 |
|---|---|---|
| committer | Teddy Wing | 2017-06-19 15:31:19 +0200 |
| commit | 84ebcffb06d9ba9a56cc29d1739f1f950649f82e (patch) | |
| tree | be26f797750b961bdcb2a9181167b8e5c371571a /app/controllers | |
| parent | ce105d1ddb7f019cf8b55e41aa69c51e651c8ac9 (diff) | |
| download | chouette-core-84ebcffb06d9ba9a56cc29d1739f1f950649f82e.tar.bz2 | |
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
Diffstat (limited to 'app/controllers')
| -rw-r--r-- | app/controllers/routes_controller.rb | 6 |
1 files changed, 6 insertions, 0 deletions
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 |
