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? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
richard schneeman
2013-Dec-16 18:11 UTC
Re: UrlHelper: Extracting url_for to separate module
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. On Sun, Dec 15, 2013 at 4:27 PM, Nick Sutterer <apotonick@gmail.com> wrote:> 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? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscribe@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at http://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.
Pier-Olivier Thibault
2013-Dec-16 22:27 UTC
Re: UrlHelper: Extracting url_for to separate module
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. On Monday, December 16, 2013 1:11:38 PM UTC-5, richard schneeman wrote:> > 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. > > > On Sun, Dec 15, 2013 at 4:27 PM, Nick Sutterer <apot...@gmail.com<javascript:> > > wrote: > >> 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? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-co...@googlegroups.com <javascript:>. >> To post to this group, send email to rubyonra...@googlegroups.com<javascript:> >> . >> Visit this group at http://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/groups/opt_out. >> > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscribe@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at http://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/groups/opt_out.