App/helpers in Rails

Hello!

I am new to ruby (and to ruby on rails). Having created some helpers
with
script/generate helper HelperName

how do I access them in controllers and views? :-/

Tuo Pe

On Saturday 28 November 2009 11:30:06 am T_P wrote:

Having created some helpers
with
script/generate helper HelperName

how do I access them in controllers and views? :-/

Probably, include them into the controller you need, or into
ApplicationController to make them available everywhere.

But I don’t know, haven’t touched Rails in awhile. Ask the Rails list.

You can specify “helper :all” in ApplicationController.rb, which will
make
all helpers available to all controllers and views.

http://api.rubyonrails.org/classes/ActionController/Helpers/ClassMethods.html#M000490

-Evan

T_P wrote:

how do I access them in controllers and views? :-/

They are available in views already.

For a method to be available both in controllers and views, define it as
a method in the ApplicationController instead:

private
def my_helper(foo)
return “#{foo}!!”
end
helper_method :my_helper