Skip to content
  • Daniel Colson's avatar
    a00e548d
    Print source location when inspecting routes · a00e548d
    Daniel Colson authored
    
    
    In larger route files, or when routes are spread across multiple files,
    it can be difficult to get from the output of the route inspector to the
    relevant route definition.
    
    This commit adds a route source location to the route, and uses that in
    the HtmlTableFormatter (for rails/info and the debug exceptions
    middleware) and the Expanded formatter (for `rails routes -E`).
    
    To avoid doing extra work in production, it only sets the source location
    in development.
    
    This commit injects the application's backtrace cleaner so we can use it
    to remove the rails root from the path. This also means we don't get
    source locations for the routes defined by Rails.
    
    If mounting an engine from a gem, we'll get a source location for where
    we mount it in the application, but not for the routes defined in the
    gem itself. That's probably good enough, since Rails already prints
    routes for an engine separately under the title "Routes for
    Foo::Engine".
    
    Co-authored-by: default avatarJohn Hawthorn <jhawthorn@github.com>
    Co-authored-by: default avatarLuan Vieira <luanzeba@github.com>
    Co-authored-by: default avatarDaniel Colson <composerinteralia@github.com>
    a00e548d
    Print source location when inspecting routes
    Daniel Colson authored
    
    
    In larger route files, or when routes are spread across multiple files,
    it can be difficult to get from the output of the route inspector to the
    relevant route definition.
    
    This commit adds a route source location to the route, and uses that in
    the HtmlTableFormatter (for rails/info and the debug exceptions
    middleware) and the Expanded formatter (for `rails routes -E`).
    
    To avoid doing extra work in production, it only sets the source location
    in development.
    
    This commit injects the application's backtrace cleaner so we can use it
    to remove the rails root from the path. This also means we don't get
    source locations for the routes defined by Rails.
    
    If mounting an engine from a gem, we'll get a source location for where
    we mount it in the application, but not for the routes defined in the
    gem itself. That's probably good enough, since Rails already prints
    routes for an engine separately under the title "Routes for
    Foo::Engine".
    
    Co-authored-by: default avatarJohn Hawthorn <jhawthorn@github.com>
    Co-authored-by: default avatarLuan Vieira <luanzeba@github.com>
    Co-authored-by: default avatarDaniel Colson <composerinteralia@github.com>
Loading