diff --git a/app/models/api_key_scope.rb b/app/models/api_key_scope.rb index 0de8dd4ca8b..d2e685d1654 100644 --- a/app/models/api_key_scope.rb +++ b/app/models/api_key_scope.rb @@ -101,7 +101,14 @@ class ApiKeyScope < ActiveRecord::Base urls = [] if actions.present? - Rails.application.routes.routes.each do |route| + routes = Rails.application.routes.routes.to_a + Rails::Engine.descendants.each do |engine| + next if engine == Rails::Application # abstract engine, can't call routes on it + next if engine == Discourse::Application # equiv. to Rails.application + routes.concat(engine.routes.routes.to_a) + end + + routes.each do |route| defaults = route.defaults action = "#{defaults[:controller].to_s}##{defaults[:action]}" path = route.path.spec.to_s.gsub(/\(\.:format\)/, '')