Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninitialized constant SwaggerController #5

Open
coldnebo opened this issue Sep 4, 2014 · 2 comments
Open

uninitialized constant SwaggerController #5

coldnebo opened this issue Sep 4, 2014 · 2 comments

Comments

@coldnebo
Copy link

coldnebo commented Sep 4, 2014

Hi, followed the example on the main README and got this error:

Started GET "/appname/swagger/api" for 127.0.0.1 at 2014-09-04 11:08:22 -0400

ActionController::RoutingError (uninitialized constant SwaggerController)

my app is mapped to /appname/swagger/api via config.ru instead of '/swagger/api'.

if defined?(WEBrick)
  map ActionController::Base.config.relative_url_root || '/' do
    run Appname::Application
  end
else
  run Appname::Application
end

I added to the routes.rb as advised:

mount SwaggerYard::Engine, at: "/swagger"

and rake routes shows the new routes, correctly.

$ rake routes
  ...
  swagger_yard_engine      /swagger                   SwaggerYard::Engine

Routes for SwaggerYard::Engine:
doc GET /doc(.:format)           swagger#doc
api GET /api(.:format)           swagger#index
    GET /api/*resource(.:format) swagger#show

Do I need an addtional require?

@coldnebo
Copy link
Author

coldnebo commented Sep 4, 2014

BTW, I found the correct constant: SwaggerYard::SwaggerController in ObjectSpace. The param[:controller] is 'swagger', which resolves to SwaggerController. I've changed this param to 'swagger_yard/swagger' in pry-rescue and it correctly resolves to SwaggerYard::SwaggerController, so it seems like some problem with pathing/loading.

coldnebo added a commit to coldnebo/swagger_yard that referenced this issue Sep 5, 2014
@coldnebo
Copy link
Author

coldnebo commented Sep 5, 2014

Ok, lot's of hacking... (i'm new to Rails Engines, so forgive some of my steps).

My fork now works with my webrick setup, however I did have to change the following:

# config/initializers/swagger_yard.rb
SwaggerYard.configure do |config|
  config.swagger_version = "1.1"
  config.api_version = "0.1"
  #config.doc_base_path = "http://swagger.example.com/doc"
  #config.api_base_path = "http://swagger.example.com/api"
end

If I leave those two lines in, then it doesn't correctly detect localhost, which I need for local development.

Apart from the rough edges, this is more or less what I need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant