1. 27 2月, 2013 2 次提交
  2. 22 2月, 2013 1 次提交
    • Y
      determine the match shorthand target early. · c88ee769
      Yves Senn 提交于
      Closes #7554.
      
      This patch determines the `controller#action` directly
      in the `match` method when the shorthand syntax is used.
      this prevents problems with namespaces and scopes.
      c88ee769
  3. 10 2月, 2013 1 次提交
  4. 07 2月, 2013 1 次提交
    • Y
      ruby constant syntax is not supported as routing `:controller` option. · 69f28a7d
      Yves Senn 提交于
      The current implementation only works correctly if you supply the `:controller`
      with directory notation (eg. `:controller => 'admin/posts'`).
      
      The ruby constant notation (eg. `:controller => 'Admin::Posts`) leads to unexpected problems with `url_for`.
      
      This patch prints a warning for every non supported `:controller` option. I also added documentation how
      to work with namespaced controllers. The warning links to that documentation in the rails guide.
      69f28a7d
  5. 22 1月, 2013 1 次提交
    • A
      Duplicate possible frozen string from route · c4106d0c
      Andrew White 提交于
      Ruby 1.9 freezes Hash string keys by default so where a route is
      defined like this:
      
        get 'search' => 'search'
      
      then the Mapper will derive the action from the key. This blows up
      later when the action is added to the parameters hash and the
      encoding is forced.
      
      Closes #3429
      c4106d0c
  6. 16 1月, 2013 2 次提交
    • A
      Change the behavior of route defaults · f1d8f2af
      Andrew White 提交于
      This commit changes route defaults so that explicit defaults are no
      longer required where the key is not part of the path. For example:
      
        resources :posts, bucket_type: 'posts'
      
      will be required whenever constructing the url from a hash such as a
      functional test or using url_for directly. However using the explicit
      form alters the behavior so it's not required:
      
        resources :projects, defaults: { bucket_type: 'projects' }
      
      This changes existing behavior slightly in that any routes which
      only differ in their defaults will match the first route rather
      than the closest match.
      
      Closes #8814
      f1d8f2af
    • A
      Add support for other types of routing constraints · 90d2802b
      Andrew White 提交于
      This now allows the use of arrays like this:
      
        get '/foo/:action', to: 'foo', constraints: { subdomain: %w[www admin] }
      
      or constraints where the request method returns an Fixnum like this:
      
        get '/foo', to: 'foo#index', constraints: { port: 8080 }
      
      Note that this only applies to constraints on the request - path
      constraints still need to be specified as Regexps as the various
      constraints are compiled into a single Regexp.
      90d2802b
  7. 04 12月, 2012 1 次提交
  8. 26 11月, 2012 1 次提交
    • A
      Improve clarity of routing tests · be2a3b0a
      Andrew White 提交于
      Move the routes for each test inside the test method so that
      it's easier to see which routes are applicable to which test.
      
      To ensure that each test wasn't invalidated the changes were
      done by first removing all of the routes, ensuring that all
      of the tests failed and then adding the routes back to each
      test one by one. One test for `assert_recognizes` was
      removed as it wasn't actually testing the defined routes and
      is now tested more thoroughly in routing_assertions_test.rb.
      
      One downside is that the test suite takes about 1s longer
      due to having to using `method_missing` for handling the url
      helpers as using `include url_helpers` isn't isolated
      for each test.
      be2a3b0a
  9. 22 11月, 2012 1 次提交
    • G
      Allow setting a symbol as path in scope on routes · 0d3a9e8a
      Guillermo Iguaran 提交于
      Was surprising found that this example doesn't work:
      
        scope :api do
          resources :users
        end
      
      and the right form to use it is:
      
        scope 'api' do
          resources :users
        end
      
      I think this should work similary as `namespace` where both are allowed.
      These two are equivalent:
      
        namespace :api do
          resources :users
        end
      
        namespace 'api' do
          resources :user
        end
      0d3a9e8a
  10. 03 11月, 2012 2 次提交
  11. 01 10月, 2012 1 次提交
  12. 19 9月, 2012 1 次提交
  13. 28 8月, 2012 1 次提交
    • S
      Add Missing Keys from Journey on failed URL format · 0b6175ac
      schneems 提交于
      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 https://github.com/rails/journey/pull/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
      0b6175ac
  14. 06 8月, 2012 1 次提交
  15. 03 8月, 2012 1 次提交
  16. 20 7月, 2012 2 次提交
  17. 18 7月, 2012 1 次提交
    • A
      Add support for optional root segments containing slashes · d8745dec
      Andrew White 提交于
      Optional segments with a root scope need to have the leading slash
      outside of the parentheses, otherwise the generated url will be empty.
      However if the route has non-optional elements then the leading slash
      needs to remain inside the parentheses otherwise the generated url
      will have two leading slashes, e.g:
      
      Blog::Application.routes.draw do
        get '/(:category)', :to => 'posts#index', :as => :root
        get '/(:category)/author/:name', :to => 'posts#author', :as => :author
      end
      
      $ rake routes
        root GET /(:category)(.:format)              posts#index
      author GET (/:category)/author/:name(.:format) posts#author
      
      This change adds support for optional segments that contain a slash,
      allowing support for urls like /page/2 for the root path, e.g:
      
      Blog::Application.routes.draw do
        get '/(page/:page)', :to => 'posts#index', :as => :root
      end
      
      $ rake routes
      root GET /(page/:page)(.:format) posts#index
      
      Fixes #7073
      d8745dec
  18. 30 6月, 2012 1 次提交
  19. 15 6月, 2012 1 次提交
  20. 25 5月, 2012 1 次提交
  21. 21 5月, 2012 1 次提交
    • A
      Return 400 Bad Request for URL paths with invalid encoding. · 3fc561a1
      Andrew White 提交于
      Passing path parameters with invalid encoding is likely to trigger errors
      further on like `ArgumentError (invalid byte sequence in UTF-8)`. This will
      result in a 500 error whereas the better error to return is a 400 error which
      allows exception notification libraries to filter it out if they wish.
      
      Closes #4450
      3fc561a1
  22. 15 5月, 2012 1 次提交
  23. 11 5月, 2012 2 次提交
  24. 09 5月, 2012 2 次提交
  25. 07 5月, 2012 1 次提交
  26. 05 5月, 2012 1 次提交
  27. 03 5月, 2012 1 次提交
    • A
      Reset the request parameters after a constraints check · 56030506
      Andrew White 提交于
      A callable object passed as a constraint for a route may access the request
      parameters as part of its check. This causes the combined parameters hash
      to be cached in the environment hash. If the constraint fails then any subsequent
      access of the request parameters will be against that stale hash.
      
      To fix this we delete the cache after every call to `matches?`. This may have a
      negative performance impact if the contraint wraps a large number of routes as the
      parameters hash is built by merging GET, POST and path parameters.
      
      Fixes #2510.
      56030506
  28. 30 4月, 2012 2 次提交
  29. 25 4月, 2012 1 次提交
    • J
      Remove default match without specified method · 56cdc81c
      Jose and Yehuda 提交于
      In the current router DSL, using the +match+ DSL
      method will match all verbs for the path to the
      specified endpoint.
      
      In the vast majority of cases, people are
      currently using +match+ when they actually mean
      +get+. This introduces security implications.
      
      This commit disallows calling +match+ without
      an HTTP verb constraint by default. To explicitly
      match all verbs, this commit also adds a
      :via => :all option to +match+.
      
      Closes #5964
      56cdc81c
  30. 26 3月, 2012 1 次提交
    • J
      Allow a defining custom member field on resources · 3e67e45d
      Jamie Macey 提交于
      By default, resources routes are created with :resource/:id. A model
      defining to_param can make prettier urls by using something more
      readable than an integer ID, but since the route picks it up as :id you
      wind up with awkward User.find_by_username(params[:id]) calls.
      
      By overriding the key to be used in @request.params you can be more
      obvious in your intent.
      3e67e45d
  31. 25 2月, 2012 2 次提交
  32. 22 2月, 2012 1 次提交