I have a number of Rails engines in a Rails app, and each currently has its own constraint class to determine whether to allow the user
mount Flipper::UI.app(Flipper) => '/admin/flipper', :as => "feature_flags", constraints: CanAccessFeaturesUI
Since Current.user
is set in the ApplicationController, it is not yet available in routes.rb
. Is there any accepted way to make it available to the router, so that I can simply do something roughly like this:
mount Flipper::UI.app(Flipper) => '/admin/flipper', :as => "feature_flags", constraints: -> do
Current&.user&.superuser?
end
Current.user
before Rails evaluates routes?