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
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
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.
On Saturday 28 November 2009 11:30:06 am T_P wrote:
Having created some helpers
with
script/generate helper HelperNamehow do I access them in controllers and views? :-/
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/\.
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@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.