Helper :all does not include Modules

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.

On Jun 2, 7:11 am, Thomas E. [email protected] wrote:

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

Fred

Thanks for the info,

Tom.

On Jun 2, 5:38 pm, Frederick C. [email protected]