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

4

1 回答 1

1

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

于 2017-05-04T08:49:43.903 回答