diff options
author | Andrew White <andrew.white@unboxed.co> | 2018-03-21 10:19:10 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2018-03-21 10:22:14 +0000 |
commit | 5368f2508651c92fbae40cd679afbafdd7e98e77 (patch) | |
tree | b933a9fecd6e9569b7fe3d25ea2395b86de2bf48 /actionpack/lib/action_dispatch | |
parent | fab6ded8f299d51593f4d68f4f9b7b03b44aa2c3 (diff) | |
download | rails-5368f2508651c92fbae40cd679afbafdd7e98e77.tar.gz rails-5368f2508651c92fbae40cd679afbafdd7e98e77.tar.bz2 rails-5368f2508651c92fbae40cd679afbafdd7e98e77.zip |
Cache url helpers module
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.
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index f3970d5445..d9dd24935b 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -664,6 +664,7 @@ module ActionDispatch def define_generate_prefix(app, name) _route = @set.named_routes.get name _routes = @set + _url_helpers = @set.url_helpers script_namer = ->(options) do prefix_options = options.slice(*_route.segment_keys) @@ -675,7 +676,7 @@ module ActionDispatch # We must actually delete prefix segment keys to avoid passing them to next url_for. _route.segment_keys.each { |k| options.delete(k) } - _routes.url_helpers.send("#{name}_path", prefix_options) + _url_helpers.send("#{name}_path", prefix_options) end app.routes.define_mounted_helper(name, script_namer) |