# \[SOLVED\] Hanami routes helper don't work in templates

**URL:** <https://discourse.hanakai.org/t/solved-hanami-routes-helper-dont-work-in-templates/333>\
**Category:** general\
**Created:** [April 18, 2017, 8:01pm UTC](https://discourse.hanakai.org/t/solved-hanami-routes-helper-dont-work-in-templates/333 "2017-04-18T20:01:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![milovidov](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/milovidov/32/270_2.png) [@milovidov](https://discourse.hanakai.org/u/milovidov)\
**Post date:** [April 18, 2017, 8:01pm UTC](https://discourse.hanakai.org/t/solved-hanami-routes-helper-dont-work-in-templates/333/1 "2017-04-18T20:01:53Z")

</div>

I have hanami application version 1.0.0  
I have next routes.rb file:

```
get '/games', to: 'games#index'
root to: 'home#index'

```

I read [docs](http://hanamirb.org/guides/helpers/routing/) and tried to use

```
<%= routes.games_path %>

```

in application.html.erb template, but recieved next error:

> Hanami::Routing::InvalidRouteException: No route (path) could be generated for :games - please check given arguments

How can I use routers in hanami templates?

---

<div class="post-metadata">

**Author:** ![mereghost](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/mereghost/32/255_2.png) [@mereghost](https://discourse.hanakai.org/u/mereghost)\
**Post date:** [April 18, 2017, 8:19pm UTC](https://discourse.hanakai.org/t/solved-hanami-routes-helper-dont-work-in-templates/333/2 "2017-04-18T20:19:45Z")

</div>

The helpers work with the [resource routes](http://hanamirb.org/guides/routing/restful-resources/) only, as they create [named routes](http://hanamirb.org/guides/routing/basic-usage/#named-routes)

---

<div class="post-metadata">

**Author:** ![milovidov](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/milovidov/32/270_2.png) [@milovidov](https://discourse.hanakai.org/u/milovidov)\
**Post date:** [April 19, 2017, 12:55pm UTC](https://discourse.hanakai.org/t/solved-hanami-routes-helper-dont-work-in-templates/333/3 "2017-04-19T12:55:17Z")

</div>

Thank you, I added  
`resources :games, only: [:index]`  
to my routes.rb file and this fixed my problem

---

<div class="post-metadata">

**Author:** ![jodosha](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/jodosha/32/710_2.png) [@jodosha](https://discourse.hanakai.org/u/jodosha)\
**Post date:** [April 21, 2017, 7:24am UTC](https://discourse.hanakai.org/t/solved-hanami-routes-helper-dont-work-in-templates/333/4 "2017-04-21T07:24:29Z")

</div>

@milovidov For the record, it worked because `resources` adds names to the routes automatically.

Just wanted to point out to have a complete picture of how routing helpers work. 😉
