From: T_P on
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
From: David Masover on
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.

From: Evan Worley on
[Note: parts of this message were removed to make it a legal post.]

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

On Sat, Nov 28, 2009 at 9:48 AM, David Masover <ninja(a)slaphack.com> wrote:

> 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.
>
>

From: Brian Candler on
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

--
Posted via http://www.ruby-forum.com/.