{"action":"created","issue":{"url":"https://api.github.com/repos/hanami/router/issues/97","repository_url":"https://api.github.com/repos/hanami/router","labels_url":"https://api.github.com/repos/hanami/router/issues/97/labels{/name}","comments_url":"https://api.github.com/repos/hanami/router/issues/97/comments","events_url":"https://api.github.com/repos/hanami/router/issues/97/events","html_url":"https://github.com/hanami/router/issues/97","id":137966220,"number":97,"title":"Automatic root_path helper?","user":{"login":"cllns","id":632942,"avatar_url":"https://avatars.githubusercontent.com/u/632942?v=3","gravatar_id":"","url":"https://api.github.com/users/cllns","html_url":"https://github.com/cllns","followers_url":"https://api.github.com/users/cllns/followers","following_url":"https://api.github.com/users/cllns/following{/other_user}","gists_url":"https://api.github.com/users/cllns/gists{/gist_id}","starred_url":"https://api.github.com/users/cllns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cllns/subscriptions","organizations_url":"https://api.github.com/users/cllns/orgs","repos_url":"https://api.github.com/users/cllns/repos","events_url":"https://api.github.com/users/cllns/events{/privacy}","received_events_url":"https://api.github.com/users/cllns/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hanami/router/labels/discussion","name":"discussion","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-02T19:20:48Z","updated_at":"2016-03-03T23:18:07Z","closed_at":null,"body":"Making a `hanami` app and defining a route at `'/'`, I expected I'd have access to a `routes.root_path` helper, but I had to add `as: :root` in order to get it.\r\n\r\nThis could that I'm accustomed to Rails, and that `hanami` prefers to be explicit, but automatically adding a `root` path for `'/'` seems like a nice feature :)"},"comment":{"url":"https://api.github.com/repos/hanami/router/issues/comments/192014954","html_url":"https://github.com/hanami/router/issues/97#issuecomment-192014954","issue_url":"https://api.github.com/repos/hanami/router/issues/97","id":192014954,"user":{"login":"cllns","id":632942,"avatar_url":"https://avatars.githubusercontent.com/u/632942?v=3","gravatar_id":"","url":"https://api.github.com/users/cllns","html_url":"https://github.com/cllns","followers_url":"https://api.github.com/users/cllns/followers","following_url":"https://api.github.com/users/cllns/following{/other_user}","gists_url":"https://api.github.com/users/cllns/gists{/gist_id}","starred_url":"https://api.github.com/users/cllns/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cllns/subscriptions","organizations_url":"https://api.github.com/users/cllns/orgs","repos_url":"https://api.github.com/users/cllns/repos","events_url":"https://api.github.com/users/cllns/events{/privacy}","received_events_url":"https://api.github.com/users/cllns/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T23:18:07Z","updated_at":"2016-03-03T23:18:07Z","body":"If my routes file looks like:\r\n```\r\n# apps/web/config/routes.rb\r\nget '/', to: 'welcome#index'\r\nresources :books\r\n```\r\n\r\nNow:\r\n```\r\n$ hanami routes\r\n                Name Method     Path                           Action\r\n\r\n                     GET, HEAD  /                              Web::Controllers::Welcome::Index\r\n               books GET, HEAD  /books                         Web::Controllers::Books::Index\r\n            new_book GET, HEAD  /books/new                     Web::Controllers::Books::New\r\n               books POST       /books                         Web::Controllers::Books::Create\r\n                book GET, HEAD  /books/:id                     Web::Controllers::Books::Show\r\n           edit_book GET, HEAD  /books/:id/edit                Web::Controllers::Books::Edit\r\n                book PATCH      /books/:id                     Web::Controllers::Books::Update\r\n                book DELETE     /books/:id                     Web::Controllers::Books::Destroy\r\n```\r\n\r\nDesired:\r\n```\r\n$ hanami routes\r\n                Name Method     Path                           Action\r\n\r\n                root GET, HEAD  /                              Web::Controllers::Welcome::Index\r\n               books GET, HEAD  /books                         Web::Controllers::Books::Index\r\n            new_book GET, HEAD  /books/new                     Web::Controllers::Books::New\r\n               books POST       /books                         Web::Controllers::Books::Create\r\n                book GET, HEAD  /books/:id                     Web::Controllers::Books::Show\r\n           edit_book GET, HEAD  /books/:id/edit                Web::Controllers::Books::Edit\r\n                book PATCH      /books/:id                     Web::Controllers::Books::Update\r\n                book DELETE     /books/:id                     Web::Controllers::Books::Destroy\r\n```\r\n\r\nSo you'd get access to `routes.root_path`, `routes.path(:root)`, `routes.url(:root)`.\r\n\r\nSo essentially, if you ever have a route for `'/'`, it gets an automatic `as: :root`. \r\n\r\nThe other option is to add `root` ([like Rails](http://guides.rubyonrails.org/routing.html#using-root) has), which essentially `get '/' to: ...` but I'm not arguing for that, though it would be slightly more explicit.\r\n\r\nDoes that answer the question?"}}