Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Missing Keys from Journey on Failed URL Format #7230

Merged
merged 2 commits into from Aug 29, 2012

Commits on Aug 28, 2012

  1. Add Missing Keys from Journey on failed URL format

    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: http://cl.ly/image/3S0T0n1T3421
    schneems committed Aug 28, 2012
    Copy the full SHA
    0b6175a View commit details
    Browse the repository at this point in the history
  2. refactor route_set generate_extras functionality

    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
    schneems committed Aug 28, 2012
    Copy the full SHA
    cc57b2a View commit details
    Browse the repository at this point in the history