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.


243
244
245
246
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 243

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

Instance Method Details

#header(routes) ⇒ Object

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


257
258
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 257

def header(routes)
end

#no_routesObject


260
261
262
263
264
265
266
267
268
269
270
271
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 260

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


273
274
275
276
277
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 273

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

#section(routes) ⇒ Object


252
253
254
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 252

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

#section_title(title) ⇒ Object


248
249
250
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 248

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