Add Missing Keys from Journey on Failed URL Format #7230

merged 2 commits into from Aug 29, 2012
Commits on Aug 28, 2012
  1. Add Missing Keys from Journey on failed URL format

    schneems committed Aug 1, 2012
    Many named routes have keys that are required to successfully resolve. If a key is left off like this:
        <%= link_to 'user', user_path %>
    This will produce an error like this:
        No route matches {:action=>"show", :controller=>"users"}
    Since we know that the :id is missing, we can add extra debugging information to the error message.
        No route matches {:action=>"show", :controller=>"users"} missing required keys: [:id]
    This will help new and seasoned developers look closer at their parameters. I've also subclassed the routing error to be clear that this error is a result of attempting to generate a url and not because the user is trying to visit a bad url. 
    While this may sound trivial this error message is misleading and confuses most developers. The important part isn't what's in the options its's what's missing. Adding this information to the error message will make debugging much more obvious. 
    This is the sister pull request of rails/journey#44 which will be required to get they missing keys into the correct error message. 
    Example Development Error in Rails:
  2. refactor route_set `generate_extras` functionality

    schneems committed Aug 27, 2012
    The result of Generator with or without the @extras instance variable set contains the desired information. Rather than preserving state when initializing the original object, we can simply extract the keys from the resultant parameters.
    ATP Actionpack, railties