-1

The overview documentation for routes has examples of objects being used for route resolution such as get '/rack-app', to: RackApp.new, which work as documented with code like:

options '/*', to: MyApp::CORSRequestHandler.new

From the console and the server commands, everything does what I expect, however, when executing the command hanami routes, I get the following error:

/path/to/gems/hanami-1.0.0/lib/hanami/config/mapper.rb:28:in `eval': uninitialized constant Hanami::Config::Mapper::MyApp (NameError)

The problem is that the routes command is not loading the entire application (which is good) but also problematic. I originally tried using require_relative from routes.rb but since the file is eval'ed this fails miserably, besides feeling wrong.

I'm trying to figure how to get this class definition included for the routes command in a way that's most consistent with Hanami itself.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
  • Please read "[mcve]" and the linked pages. When asking about a problem with your code we need the minimum code necessary to demonstrate the problem in the question itself, along with any necessary input. Without that you're asking us to imagine your code, and we can imagine all sorts of things that likely are not true. – the Tin Man May 03 '17 at 19:01

1 Answers1

1

Please try to require your Rack app from application.rb. That file is evaluated even for hanami routes command.

Luca Guidi
  • 1,201
  • 10
  • 10