UrlHelper: Extracting url_for to separate module

The UrlHelper#url_for method introduced in Rails 4 causes serious trouble for our gems Cells + Apotomo: #url_helper assumes that it is later overwritten by the real #url_for. While this works in standard setups, it fails when you have cells or widgets in engines.

I find this assumption a bit dangerous and sketchy. In the long-term we should just have one #url_for method that does exactly what it is supposed to do and that doesn’t assume it is overwritten at some later point.

For now, I suggest we extract #url_for into a separate helper that can be explicitely excluded.

module UrlForHelper def url_for end

module UrlHelper include UrlForHelper

def link_to … end

Does anyone see a problem with that?

Do you have a PR you could send over? I’m taking the silence here as either a :+1: or people have no idea what you’re talking about.

Cleaning up url_for is a pretty huge task. By putting it into a module are you suggesting that a user would need to manually include it? I’m not sure how one excludes a module if it has already been included.

A subclass should have no idea about how a superclass would consume its methods, so the behavior you’re describing should be fixed provided there’s not huge performance problems or massive backwards breakage.

url_for is not a trivial thing, it’s intertwined with many aspect of rails.

I agree that it’s not trivial to use url_for to link dynamically different engine’s routing. I think I understand your frustration with the routing system and rails::engine.