# Helper :all does not include Modules

**URL:** <https://www.ruby-forum.com/t/helper-all-does-not-include-modules/139244>\
**Category:** Rails\
**Created:** [June 2, 2008, 9:13am UTC](https://www.ruby-forum.com/t/helper-all-does-not-include-modules/139244 "2008-06-02T09:13:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@Thomas\_E](https://www.ruby-forum.com/u/Thomas_E)\
**Post date:** [June 2, 2008, 9:13am UTC](https://www.ruby-forum.com/t/helper-all-does-not-include-modules/139244/1 "2008-06-02T09:13:56Z")

</div>

Greetings list,

I was wondering if any of you are unable to call “helper” methods in  
your controllers even though application.rb has a call to  
“helper :all”?

My views are able to call the methods but my controllers are unable to  
call them unless I “include ModuleHelper” in the controller but I was  
under the impression that helper :all is supposed to take care of the  
“including”.

My development environment is  
Rails 2.1.0

application.rb snippet::

* * *

class ApplicationController \< ActionController::Base  
helper :all # include all helpers, all the time (but doesn’t seem  
to)

#controllers can call helper methods from this helper below only if  
the line below is uncommented.  
#include AuthenticateHelper

# See ActionController::RequestForgeryProtection for details

# Uncomment the :secret if you’re not using the cookie session store

protect\_from\_forgery :secret =\> ‘xxxxxxxxxxxxxxxxxxxxxxxxxxxxx’

## end

user\_controller.rb snippet::

* * *

class UserController \< ApplicationController  
before\_filter :protect, :only =\> :index

def index  
end

# Call to logged\_in? (in the method below) which is a helper module

method does not work unless

# the module is explicitely included in the ApplicationController or

this specific controller

def protect  
unless logged\_in?  
session[:protected\_page] = request.request\_uri  
flash[:notice] = “Please log in first”  
redirect\_to :action =\> “login”  
return false  
end  
end

## private :protect end

authenticate\_helper.rb snippet::

* * *

module AuthenticateHelper

# Checks if a user is logged in

def logged\_in?  
not session[:user\_id].nil?  
end

end

* * *

Calling the helper method on a single module helper doesn’t seem to  
bring the methods into the controller either.

* * *

helper :authenticate

# or

## helper AuthenticateHelper

Standard, simple code. Any help is much appreciated.

Tom.

---

<div class="post-metadata">

**Author:** ![Thomas\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@Thomas\_E](https://www.ruby-forum.com/u/Thomas_E)\
**Post date:** [June 2, 2008, 9:39am UTC](https://www.ruby-forum.com/t/helper-all-does-not-include-modules/139244/2 "2008-06-02T09:39:51Z")

</div>

On Jun 2, 7:11 am, Thomas E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

The helper method is for including modules (or controller methods)  
into views. It’s not supposed to do anything to controllers.

Fred

---

<div class="post-metadata">

**Author:** ![Thomas\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8c91f0/32.png) [@Thomas\_E](https://www.ruby-forum.com/u/Thomas_E)\
**Post date:** [June 2, 2008, 11:24am UTC](https://www.ruby-forum.com/t/helper-all-does-not-include-modules/139244/3 "2008-06-02T11:24:49Z")

</div>

Thanks for the info,

Tom.

On Jun 2, 5:38 pm, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
