Sha256: 2f05a46db1ccd4c1e368730b345a1e3da44c3176bcc24f44d60383c4999858d2
Contents?: true
Size: 1.21 KB
Versions: 9
Compression:
Stored size: 1.21 KB
Contents
class RailsInfo::RoutesPresenter < ::RailsInfo::Presenter def accordion routes = request.env['action_dispatch.routes'].routes.map do |route| { source: (route.verb.respond_to?(:source) ? route.verb.source : route.verb).gsub(/[$^]/, ''), spec: route.path.respond_to?(:spec) ? route.path.spec.to_s : route.path, name: route.name, requirements: route.requirements.inspect } end namespaced_routes = {} routes.each do |route| namespace = '/' unless route[:spec] == namespace spec = route[:spec].split('/') spec.shift namespace = spec.shift end namespaced_routes[namespace] ||= [] namespaced_routes[namespace] << route end content_tag :div, class: 'accordions' do html = '' namespaced_routes.each do |namespace, routes| html += content_tag( :h3, raw(" #{namespace}") ) table = render partial: 'rails_info/routes/table', locals: { routes: routes } html += content_tag :div, raw(table), style: "max-height:300px; overflow: auto" end raw html end end end
Version data entries
9 entries across 9 versions & 1 rubygems