Why can I access helper methods for one controller in the views for a different controller? Is there a way to disable this without hacking/patching Rails?
In Rails 3, actioncontroller/base.rb (around line 224):
def self.inherited(klass)
super
klass.helper :all if klass.superclass == ActionController::Base
end
So yes, if you derive your class from ActionController::Base, all helpers will be included.
To come around this, call clear_helpers (AbstractClass::Helpers; included in ActionController::Base) at the beginning of your controller's code. Source code comment for clear_helpers:
# Clears up all existing helpers in this class, only keeping the helper
# with the same name as this class.
E.g.:
class ApplicationController < ActionController::Base
clear_helpers
...
end