Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Avoid potentially expensive inspect call in router

#4491

The attached patch defers the creation of a routing error message in ActionDispatch::Routing::RouteSet::Generator#generate which invoke inspect on the argument of url_for (or any routing helper method actually).

This call might be expensive, especially when the argument happens to be a database record with blob fields, and is currently executed even if the route is valid.

For example, when using SlimScrooge with the following view:

<%= link_to foo.name, foo %>
SELECTed fields are expected to be id and name, but happen to be all fields from the table.

The patch applies on HEAD and fixes the above-mentioned issue, all tests are passing.

Reported by Samuel Lebeau · April 27th, 2010 @ 10:24 PM

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low