- 08 10月, 2015 1 次提交
-
-
由 Matthew Erhard 提交于
When generating the url for a mounted engine through its proxy, the path should be the sum of three parts: 1. Any `SCRIPT_NAME` request header or the value of `ActionDispatch::Routing::RouteSet#relative_url_root`. 2. A prefix (the engine's mounted path). 3. The path of the named route inside the engine. Since commit https://github.com/rails/rails/commit/44ff0313c121f528a68b3bd21d6c7a96f313e3d3, this has been broken. Step 2 has been changed to: 2. A prefix (the value of `ActionDispatch::Routing::RouteSet#relative_url_root` + the engine's mounted path). The value of `ActionDispatch::Routing::RouteSet#relative_url_root` is taken into account in step 1 of the route generation and should be ignored when generating the mounted engine's prefix in step 2. This commit fixes the regression by having `ActionDispatch::Routing::RouteSet#url_for` check `options[:relative_url_root]` before falling back to `ActionDispatch::Routing::RouteSet#relative_url_root`. The prefix generating code then sets `options[:relative_url_root]` to an empty string. This empty string is used instead of `ActionDispatch::Routing::RouteSet#relative_url_root` and avoids the duplicate `relative_url_root` value in the final result. This resolves #20920 and resolves #21459
-
- 26 8月, 2015 4 次提交
-
-
由 Aaron Patterson 提交于
Controllers should always have a request and response when responding. Since we make this The Rule(tm), then controllers don't need to be somewhere in limbo between "asking a response object for a rack response" or "I, myself contain a rack response". This duality leads to conditionals spread through the codebase that we can delete: * https://github.com/rails/rails/blob/85a78d9358aa728298cd020cdc842b55c16f9549/actionpack/lib/action_controller/metal.rb#L221-L223
-
由 Aaron Patterson 提交于
This saves a lambda and request allocation on each request.
-
由 Aaron Patterson 提交于
controllers should always go through the `action` class method so that their middleware is respected.
-
由 Aaron Patterson 提交于
now the caller can just treat it like a regular controller even though it will return a 404
-
- 25 8月, 2015 5 次提交
-
-
由 Aaron Patterson 提交于
the dispatcher class isn't configurable anymore, so pull up allocation to the method that needs it.
-
由 Aaron Patterson 提交于
Now that we don't have subclasses depending on this method (they augment the request class instead of the dispatch class) we can remove this method and directly ask the request object for the controller class
-
由 Aaron Patterson 提交于
-
由 Aaron Patterson 提交于
we don't need it anymore. We always use the same dispatcher in tests.
-
由 Aaron Patterson 提交于
controller class resolution has been moved to the request object, so we should override that method instead of relying on the RouteSet to generate the controller class.
-
- 23 8月, 2015 2 次提交
-
-
由 deepj 提交于
-
由 eileencodes 提交于
Since none of the action pack tests failed without this conditional it didn't seem necessary. This fixes the build because it correctly returns a 404 instead of a 500 for the asset routes test. Test that was failing was in the `assets_test.rb` file and was the test named `test_assets_routes_are_not_drawn_when_compilation_is_disabled`.
-
- 22 8月, 2015 2 次提交
-
-
由 eileencodes 提交于
This refactoring moves the controller class name that was on the route set to the request. The purpose of this refactoring is for changes we need to move controller tests to integration tests, mainly being able to access the controller on the request instead of having to go through the router. [Eileen M. Uchitelle & Aaron Patterson]
-
由 eileencodes 提交于
`ActiveSupport::Dependencies.constantize(const_name)` calls `Reference.new` which is defined as `ActiveSupport::Dependencies.constantize(const_name)` meaning this call is already cached and we're doing caching that isn't necessary.
-
- 19 8月, 2015 1 次提交
-
-
由 Aaron Patterson 提交于
nobody should be touching the routes hash without going through the NamedRouteCollection object.
-
- 15 8月, 2015 6 次提交
-
-
由 Aaron Patterson 提交于
The outer router object already keeps a hash of named routes, so we should just use that.
-
由 Aaron Patterson 提交于
refactor the tests with a backwards compatible method call so we can rm add_route2 from the journey router
-
由 Aaron Patterson 提交于
then we can let the mapping object derive stuff that the Route object needs.
-
由 Aaron Patterson 提交于
now that we aren't doing options manipulations, we can just pass the mapping object down and read values from it.
-
由 Aaron Patterson 提交于
now we don't need to add it to a hash and delete it from the hash later just to pass it around
-
由 Aaron Patterson 提交于
we don't need to keep adding it and deleting if from hashes.
-
- 14 8月, 2015 5 次提交
-
-
由 Aaron Patterson 提交于
It just constructs a Path::Pattern object with the AST that it already has
-
由 Aaron Patterson 提交于
This was a useless object. We can just directly construct a Path::Pattern object without a Strexp object.
-
由 Aaron Patterson 提交于
the caller already has it, there is no reason to pack it in to an object and just throw that object away.
-
由 Aaron Patterson 提交于
-
由 Aaron Patterson 提交于
we always pass all parameters, so there is no reason to provide default arguments.
-
- 10 8月, 2015 3 次提交
-
-
由 Rafael Mendonça França 提交于
This method raises conditionally not always so we should not documment as it always raise.
-
由 Rafael Mendonça França 提交于
-
由 Rafael Mendonça França 提交于
We should return when the contoller key is not present or if the controller doesn't exist and we didn't raised an error.
-
- 09 8月, 2015 5 次提交
-
-
由 Aaron Patterson 提交于
we need to get a grip on what `scope` actually does. This commit removes some of the internal calls to `scope`. Eventually we should add public facing methods that provide the API that `scope` is trying to accomplish.
-
由 Aaron Patterson 提交于
`prepare_params!` would raise an exception if `params` wasn't initialized, so it must always be available. Remove the existence conditional from the `controller` method.
-
由 Aaron Patterson 提交于
The method we called already has the conditional we need. Just add an else block so that we don't need two tests.
-
由 Aaron Patterson 提交于
`Dispatcher` doesn't need to hold on to the defaults hash. It only used the hash to determine whether or not it should raise an exception if there is a name error. We can pass that in further up the stack and alleviate Dispatcher from knowing about that hash.
-
由 Aaron Lasseigne 提交于
Using each_key is faster and more intention revealing. Calculating ------------------------------------- each 31.378k i/100ms each_key 33.790k i/100ms ------------------------------------------------- each 450.225k (± 7.0%) i/s - 2.259M each_key 494.459k (± 6.3%) i/s - 2.467M Comparison: each_key: 494459.4 i/s each: 450225.1 i/s - 1.10x slower
-
- 08 8月, 2015 3 次提交
-
-
由 Xavier Shay 提交于
-
由 Xavier Shay 提交于
scope so that they are available to subclasses.
-
由 Aaron Patterson 提交于
-
- 02 8月, 2015 1 次提交
-
-
由 Benjamin Quorning 提交于
While the readability may be slightly worse, the speed improvement is significant: Twice as fast when there's no leading "/" to remove, and over 4 times as fast when there is a leading "/". Benchmark: require 'benchmark/ips' def match(controller) if controller if m = controller.match(/\A\/(?<controller_without_leading_slash>.*)/) m[:controller_without_leading_slash] else controller end end end def start_with(controller) if controller if controller.start_with?('/'.freeze) controller[1..-1] else controller end end end Benchmark.ips do |x| x.report("match") { match("no_leading_slash") } x.report("start_with") { start_with("no_leading_slash") } x.compare! end Benchmark.ips do |x| x.report("match") { match("/a_leading_slash") } x.report("start_with") { start_with("/a_leading_slash") } x.compare! end Result (Ruby 2.2.2): Calculating ------------------------------------- match 70.324k i/100ms start_with 111.264k i/100ms ------------------------------------------------- match 1.468M (± 7.1%) i/s - 7.314M start_with 3.787M (± 3.5%) i/s - 18.915M Comparison: start_with: 3787389.4 i/s match: 1467636.4 i/s - 2.58x slower Calculating ------------------------------------- match 36.694k i/100ms start_with 86.071k i/100ms ------------------------------------------------- match 532.795k (± 4.7%) i/s - 2.679M start_with 2.518M (± 5.8%) i/s - 12.566M Comparison: start_with: 2518366.8 i/s match: 532794.5 i/s - 4.73x slower
-
- 01 8月, 2015 1 次提交
-
-
由 yui-knk 提交于
`Array#to_param` is defind in active_support/core_ext/object/to_query.rb, so we can call `to_param` if value is_a Array.
-
- 31 7月, 2015 1 次提交
-
-
由 schneems 提交于
If we don't mutate the `recall` hash, then there's no reason to duplicate it. While this change doesn't get rid of that many objects, each hash object it gets rid of was massive. Saves 888 string objects per request, 206,013 bytes (thats 0.2 mb which is kinda a lot).
-