Add after-initialize checker to add routes to reserved words (#471)

This commit is contained in:
Ben Halpern 2018-06-21 12:24:47 -04:00 committed by GitHub
parent aed3c81e8d
commit 45ad83455a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,5 +43,19 @@ module PracticalDeveloper
# Replace with a lambda or method name defined in ApplicationController
# to implement access control for the Flipflop dashboard.
config.flipflop.dashboard_access_filter = -> { head :forbidden unless current_user.has_any_role?(:super_admin) }
config.after_initialize do
Rails.application.reload_routes!
top_routes = []
Rails.application.routes.routes.each do |route|
route = route.path.spec.to_s
unless route.starts_with?('/:')
route = route.split('/')[1]
route = route.split('(')[0] if route && route.include?('(')
top_routes << route
end
end
::RESERVED_WORDS = [RESERVED_WORDS + top_routes].flatten.compact.uniq
end
end
end