# How to use a helper which is not inside app/helpers/

**URL:** <https://www.ruby-forum.com/t/how-to-use-a-helper-which-is-not-inside-app-helpers/51665>\
**Category:** Rails\
**Created:** [January 5, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/how-to-use-a-helper-which-is-not-inside-app-helpers/51665 "2006-01-05T17:44:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saiho\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@Saiho\_Y](https://www.ruby-forum.com/u/Saiho_Y)\
**Post date:** [January 5, 2006, 5:44pm UTC](https://www.ruby-forum.com/t/how-to-use-a-helper-which-is-not-inside-app-helpers/51665/1 "2006-01-05T17:44:37Z")

</div>

Hi,

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

Saiho

* * *

Yahoo! DSL ? Something to write home about.  
Just $16.99/mo. or less.  
[dsl.yahoo.com](http://dsl.yahoo.com)

---

<div class="post-metadata">

**Author:** ![Saiho\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@Saiho\_Y](https://www.ruby-forum.com/u/Saiho_Y)\
**Post date:** [January 5, 2006, 7:57pm UTC](https://www.ruby-forum.com/t/how-to-use-a-helper-which-is-not-inside-app-helpers/51665/2 "2006-01-05T19:57:29Z")

</div>

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)  
formatting\_helper.rb:

module FormattingHelper

def format\_time(time, format\_str = “%m/%d/%Y  
%I:%M:%S %p”)  
time.strftime(format\_str)  
end  
end

Now in your controller add

helper :formatting

In your views you can access format\_time. E.g.:

Started on: \<%= format\_time @task.created\_at %\>

Hope this helps.

Stephen V.

---

<div class="post-metadata">

**Author:** ![Saiho\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b38774/32.png) [@Saiho\_Y](https://www.ruby-forum.com/u/Saiho_Y)\
**Post date:** [January 5, 2006, 9:21pm UTC](https://www.ruby-forum.com/t/how-to-use-a-helper-which-is-not-inside-app-helpers/51665/3 "2006-01-05T21:21:38Z")

</div>

Hi,

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/environment.rb

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

Saiho

— Stephen V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> end
> 
> Started on: \<%= format\_time @task.created\_at which is \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ \> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Rails mailing list removed\_email\_address@domain.invalid http://lists.rubyonrails.org/mailman/listinfo/rails

* * *

Yahoo! DSL ? Something to write home about.  
Just $16.99/mo. or less.  
[dsl.yahoo.com](http://dsl.yahoo.com)
