1. 28 9月, 2018 1 次提交
    • S
      Fixing an edge case when using objects as constraints · d043920e
      Simon Courtois 提交于
      This PR fixes an issue when the following situation occurs.
      If you define a class like this
      
          class MyConstraint
            def call(*args)
              # for some reason this is defined
            end
      
            def matches?(*args)
              # checking the args
            end
          end
      
      and try to use it as a constraint
      
          get "/", to: "home#show", constraints: MyConstraint.new
      
      if its `matches?` method returns `false` there will be an error for the
      mapper will ask for the constraint arity, thinking it is a proc, lambda
      or method.
      
      This PR checks for the presence of the `arity` method on the constraint
      calling it only if present, preventing the error while keeping the basic
      behavior.
      d043920e
  2. 26 9月, 2018 1 次提交
    • A
      Eagerly build the routing helper module after routes are committed · 8dc78429
      Aaron Patterson 提交于
      This commit eagerly builds the route helper module after the routes have
      been drawn and finalized.  This allows us to cache the helper module but
      not have to worry about people accessing the module while route
      definition is "in-flight", and automatically deals with cache
      invalidation as the module is regenerated anytime someone redraws the
      routes.
      
      The restriction this commit introduces is that the url helper module can
      only be accessed *after* the routes are done being drawn.
      
      Refs #24554 and #32892
      8dc78429
  3. 23 9月, 2018 1 次提交
    • Y
      Enable `Performance/UnfreezeString` cop · 1b86d901
      yuuji.yaginuma 提交于
      In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.
      
      ```ruby
      # frozen_string_literal: true
      
      require "bundler/inline"
      
      gemfile(true) do
        source "https://rubygems.org"
      
        gem "benchmark-ips"
      end
      
      Benchmark.ips do |x|
        x.report('+@') { +"" }
        x.report('dup') { "".dup }
        x.compare!
      end
      ```
      
      ```
      $ ruby -v benchmark.rb
      ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
      Warming up --------------------------------------
                        +@   282.289k i/100ms
                       dup   187.638k i/100ms
      Calculating -------------------------------------
                        +@      6.775M (± 3.6%) i/s -     33.875M in   5.006253s
                       dup      3.320M (± 2.2%) i/s -     16.700M in   5.032125s
      
      Comparison:
                        +@:  6775299.3 i/s
                       dup:  3320400.7 i/s - 2.04x  slower
      
      ```
      1b86d901
  4. 25 8月, 2018 1 次提交
  5. 29 7月, 2018 1 次提交
  6. 24 7月, 2018 1 次提交
  7. 21 3月, 2018 1 次提交
    • A
      Cache url helpers module · 5368f250
      Andrew White 提交于
      The urls helpers module returned by Rails.application.routes.url_helpers
      isn't cached so to prevent the cost of building the module cache it locally.
      5368f250
  8. 17 2月, 2018 1 次提交
  9. 20 1月, 2018 1 次提交
  10. 23 11月, 2017 1 次提交
    • T
      Fix CustomUrls#direct doc formatting · f7f7a08f
      T.J. Schuck 提交于
      Particularly, the bulleted list was getting formatted as a code block because of the extra level of indentation.  Pulling it back to the left makes it render properly as a list instead.
      
      [ci skip]
      f7f7a08f
  11. 04 11月, 2017 1 次提交
  12. 21 10月, 2017 1 次提交
  13. 19 8月, 2017 1 次提交
  14. 18 8月, 2017 1 次提交
  15. 24 7月, 2017 1 次提交
  16. 11 7月, 2017 1 次提交
  17. 07 7月, 2017 1 次提交
  18. 06 7月, 2017 1 次提交
  19. 02 7月, 2017 1 次提交
  20. 01 7月, 2017 2 次提交
  21. 04 6月, 2017 1 次提交
  22. 03 6月, 2017 1 次提交
  23. 18 4月, 2017 1 次提交
    • A
      Use more specific check for :format in route path · 8776a713
      Andrew White 提交于
      The current check for whether to add an optional format to the path
      is very lax and will match things like `:format_id` where there are
      nested resources, e.g:
      
          resources :formats do
            resources :items
          end
      
      Fix this by using a more restrictive regex pattern that looks for
      the patterns `(.:format)`, `.:format` or `/` at the end of the path.
      Note that we need to allow for multiple closing parenthesis since
      the route may be of this form:
      
          get "/books(/:action(.:format))", controller: "books"
      
      This probably isn't what's intended since it means that the default
      index action route doesn't support a format but we have a test for
      it so we need to allow it.
      
      Fixes #28517.
      8776a713
  24. 14 3月, 2017 1 次提交
  25. 06 3月, 2017 1 次提交
    • Y
      Fix `direct` with params example [ci skip] · 0c1ff424
      yuuji.yaginuma 提交于
      Since `ActionController:Parameters` does not inherit `Hash`, need to
      explicitly convert it to `Hash`.
      Also, `Parameters#to_h` returns `Hash` whose key is `String`. Therefore,
      if merge as it is, the value will not be overwritten as expected.
      0c1ff424
  26. 26 2月, 2017 1 次提交
  27. 23 2月, 2017 2 次提交
    • A
      [ci skip] Fix more quotes in direct/resolve docs · fd85bec2
      Andrew White 提交于
      Also correct use of `direct class:` to `resolve` in example.
      fd85bec2
    • A
      Clarify use of params in `direct` · 630e709e
      Andrew White 提交于
      Since a `direct` url helper block is evaluated using `instance_exec`
      then methods that are available in the instance context can be
      accessed, e.g. the params object in a controller action or view.
      
      This wasn't clear from the example so expand on that point and add
      a test case for this situation.
      630e709e
  28. 22 2月, 2017 1 次提交
  29. 21 2月, 2017 7 次提交
  30. 16 1月, 2017 1 次提交
  31. 04 1月, 2017 1 次提交
  32. 24 12月, 2016 1 次提交