app/helpers in Rails

T

T_P

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
 
D

David Masover

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

Brian Candler

T_P said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top