Closed SamMolokanov closed 7 years ago
Seems reasonable. Maybe try to contribute this?
I have thought again about inheriting and found that GrapeSwaggerRails is mounted as Rails Engine. At this point dependency injection from main application into an engine does not look like a good idea :) So, may be using of constraint-based restriction in routes would be good enough:
# config/routes.rb
# for Devise
authenticate :user do
mount GrapeSwaggerRails::Engine => '/swagger'
end
# for request-based auth logic
constraints lambda { |request| SomeCustomAuthLogic.allow?(request) } do
mount GrapeSwaggerRails::Engine => '/swagger'
end
Hi there!
In modern Rails versions all controllers inherit from
ApplicationController
, butGrapeSwaggerRails::ApplicationController
inheritsActionController::Base
. By this reason methods that are defined atApplicationController
are not accessible from GrapeSwaggerRails context.For example, if we have defined a method
current_user
in Rails ApplicationControllerIf we use method
current_user
in abefore_filter
hook as described here, we have an error:This problem could be solved if
GrapeSwaggerRails::ApplicationController
inherits standardApplicationController
Thanks for reading this!