Class: ActionDispatch::Routing::HtmlTableFormatter

Inherits:
Object
  • Object
show all
Defined in:
actionpack/lib/action_dispatch/routing/inspector.rb

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ HtmlTableFormatter

Returns a new instance of HtmlTableFormatter.



334
335
336
337
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 334

def initialize(view)
  @view = view
  @buffer = []
end

Instance Method Details



351
352
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 351

def footer(routes)
end

#header(routes) ⇒ Object

The header is part of the HTML page, so we don’t construct it here.



348
349
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 348

def header(routes)
end

#no_routesObject



354
355
356
357
358
359
360
361
362
363
364
365
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 354

def no_routes(*)
  @buffer << <<~MESSAGE
    <p>You don't have any routes defined!</p>
    <ul>
      <li>Please add some routes in <tt>config/routes.rb</tt>.</li>
      <li>
        For more information about routes, please see the Rails guide
        <a href="https://guides.rubyonrails.org/routing.html">Rails Routing from the Outside In</a>.
      </li>
    </ul>
  MESSAGE
end

#resultObject



367
368
369
370
371
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 367

def result
  @view.raw @view.render(layout: "routes/table") {
    @view.raw @buffer.join("\n")
  }
end

#section(routes) ⇒ Object



343
344
345
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 343

def section(routes)
  @buffer << @view.render(partial: "routes/route", collection: routes)
end

#section_title(title) ⇒ Object



339
340
341
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 339

def section_title(title)
  @buffer << %(<tr><th colspan="5">#{title}</th></tr>)
end