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


186
187
188
189
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 186

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.


200
201
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 200

def header(routes)
end

#no_routesObject


203
204
205
206
207
208
209
210
211
212
213
214
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 203

def no_routes(*)
  @buffer << <<-MESSAGE.strip_heredoc
    <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="http://guides.rubyonrails.org/routing.html">Rails Routing from the Outside In</a>.
      </li>
    </ul>
    MESSAGE
end

#resultObject


216
217
218
219
220
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 216

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

#section(routes) ⇒ Object


195
196
197
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 195

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

#section_title(title) ⇒ Object


191
192
193
# File 'actionpack/lib/action_dispatch/routing/inspector.rb', line 191

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