views:

801

answers:

2

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?

+10  A: 

Delete the following line from ApplicationController

helper :all

In this way each controller will load its own helpers.

Simone Carletti
+1  A: 

Actually in Rails 2, the default functionality of ActionController::Base was to include all helpers.

Changeset 6222 on 02/24/07 20:33:47 (3 years ago) by dhh: Make it a default assumption that you want all helpers, all the time (yeah, yeah)

change:

class ApplicationController < ActionController::Base 
  helper :all # include all helpers, all the time 
end 

As of Rails 3 beta 1, that is no longer the case as noted in the CHANGELOG:

  • Added that ActionController::Base now does helper :all instead of relying on the default ApplicationController in Rails to do it [DHH]
databyte
so does that mean in Rails 3, all helpers are by default all the time loaded?
Nik