From 9e667a5a33e50bde6b6b30ce47c425bbdd063c06 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Wed, 17 Aug 2016 15:29:54 +0100 Subject: [PATCH] MonkeyPatch UrlHelper for broken routing > When there's an optional scope, `link_to resource` doesn't seem to work > properly in rails 4 The fix was taken from https://git.io/v6otV. It looks like this is still an issue, so we might want to extract this monkeypatch out in to its own file if it's still broken by the time we get to Rails 4.2. - https://github.com/svenfuchs/routing-filter/issues/47 - https://github.com/rails/rails/issues/12178 - https://github.com/rails/rails/pull/22767 --- lib/routing_filters.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/routing_filters.rb b/lib/routing_filters.rb index 972b0eb21de..68ae255c23f 100644 --- a/lib/routing_filters.rb +++ b/lib/routing_filters.rb @@ -33,3 +33,9 @@ def locales=(locales) end end end + +ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper.class_eval do + def self.optimize_helper?(route) + false + end +end