2

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 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?

synacker
  • 1,722
  • 13
  • 32

2 Answers2

5

Instead of using resources, you can also add a name to your route:

get '/games', to: 'games#index', as: :games

Read more at: https://guides.hanamirb.org/routing/overview/

wuarmin
  • 3,274
  • 3
  • 18
  • 31
Luca Guidi
  • 1,201
  • 10
  • 10
1

I added

resources :games, only: [:index]

to my routes.rb file and this fixed my problem.

synacker
  • 1,722
  • 13
  • 32