Forum: Ruby on Rails how to use a helper which is not inside app/helpers/

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Saiho Y. (Guest)
on 2006-01-05 18:44
(Received via mailing list)

I wish to know it is possible to use a helper which is
not inside the folder 'app/helpers', if it is
possbile, what should I do?

Thanks you very much!!!!


Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
Stephen V. (Guest)
on 2006-01-05 20:57
(Received via mailing list)
Edit config/environment.rb:

Uncomment config.load_path and add the path that contains your helper.
E.g., if your helper is in dir src/rails/helpers and your rails app is
called plan and is located in src/plan, add this to environment.rb:

  config.load_paths += %W( #{RAILS_ROOT}/extras
                           #{RAILS_ROOT}/../rails/helpers )

Create a file in src/rails/helpers called (for example)

module FormattingHelper

  def format_time(time, format_str = "%m/%d/%Y<br />%I:%M:%S %p")

Now in your controller add

  helper :formatting

In your views you can access format_time. E.g.:

<p>Started on: <%= format_time @task.created_at %></p>

Hope this helps.

Stephen V.
Saiho Y. (Guest)
on 2006-01-05 22:21
(Received via mailing list)

thanks you very much for the information, however, I
have tried the cmd "config.load_path", but it doesn't
work, I have felling that rails doesn't not recognized
the path that I added.

actually, the extra helper modules is outside of the
application rails file structure. (I'm using linux)

the extra helpers is stored at /opt/web/extra/helpers/
so I added the following line at the

config.load_paths += %W("/opt/web/extra/helpers/")
and in my controller I added

helper :extra (which the module name is extraHelper,
and the filename is extra_helper.rb)

rails seems to ignore that. when I try to shoe the
webpage, I got error that rails is not able to locate
the extra_helper in /app/helpers/

How can I tell rails that it should look in
/opt/web/extra/helpers/ instead of /app/helpers/?

Thanks you very much


--- Stephen V. <removed_email_address@domain.invalid> wrote:

>   end
> <p>Started on: <%= format_time @task.created_at
> which is
> > __________________________________________
> > _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid

Yahoo! DSL ? Something to write home about.
Just $16.99/mo. or less.
This topic is locked and can not be replied to.