Referencing a different app’s routes in Hanami

Posted on December 23, 2016

Ah yeah, it’s been awhile since I updated this blog. Life and work have just been super busy recently.

Anyway, I wanted to knock out a quick post about a Ruby framework I’ve been using called Hanami. It’s a really nice little framework that, to me anyway, is the most viable alternative to using Rails. I’ll be writing here and a few other places about how to use Hanami to set up authentication, authorization, and a bunch of other topics as I come across them.

So in Hanami, you create a number of apps (similar to Django), and each app is its own standalone bunch of code. For doing routing, you normally do routes.foo_path or App::Routes.path(:foo). But if you’re trying to reference a different app’s routes, neither of these works. The solution is simply to use Otherapp.routes, and work from there. So for example, Otherapp.routes.bar_path would get you the :bar path in Otherapp.

I promise future posts will be more interesting.

One response to “Referencing a different app’s routes in Hanami”

  1. none says:

    Awesome! Thanks great post. I got other app routes.

Leave a Reply

Your email address will not be published. Required fields are marked *