Jesse Storimer
2010-Aug-24 13:10 UTC
[PATCH] Ensure that not all helpers are loaded for subclasses of ActionController::Base.
Hi, I came across this issue while upgrading my app to Rails 3. ActionController::Base is defining an inherited block that tells all ancestors to use `helper :all`. This is not the right default behaviour for controllers. In most views you''ll simply want to have the designated helper available and the application helper. By calling `helper :all`, all modules from app/helpers are sorted alphabetically and then included in the view. This has the side effect that the designated helper for this controller (ie. ProductsHelper for ProductsController) may not be the first helper in the scope of your view. This becomes a problem because the app I''m upgrading has conventions whereby a lot of helpers define a #title helper, for instance, that behaves differently in different views. By calling `helper :all` in my controller there is a good chance that the helper call will be sent to the wrong module, giving me the wrong result. Here is how to reproduce the issue on the gem version of 3.0.0.rc: http://gist.github.com/517669 I''ve opened a ticket on lighthouse (and included a patch). Technically the patch doesn''t include a new test, but I added a method to one of the existing helper modules defined in the fixtures. Without my change one of the existing tests will fail because it will call the wrong helper method. Ticket is https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5348-visibility-of-helpers-seems-all-wrong Jesse -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.