# Accessing helpers in ApplicationHelper

**URL:** <https://www.ruby-forum.com/t/accessing-helpers-in-applicationhelper/90414>\
**Category:** Rails\
**Created:** [March 28, 2007, 3:46pm UTC](https://www.ruby-forum.com/t/accessing-helpers-in-applicationhelper/90414 "2007-03-28T15:46:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![viciu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@viciu](https://www.ruby-forum.com/u/viciu)\
**Post date:** [March 28, 2007, 3:46pm UTC](https://www.ruby-forum.com/t/accessing-helpers-in-applicationhelper/90414/1 "2007-03-28T15:46:17Z")

</div>

Hi!

I want to write custom helper, accessible for all views and I want to  
use other helpers like form\_remote\_tag.

I tried first to move .rhtml template code and parse it with ERB:

module ApplicationHelper  
def search\_box  
str = %|  
\<%= form\_remote\_tag(:url =\> {:controller =\> :search, :action =\>  
‘search’},  
:update =\> ‘search\_results’) do %\>  
blah blah  
\<% end %\>  
|  
return ERB.new(str).run  
end

But I’ve got ActionView::TemplateError (undefined method  
`form\_remote\_tag’ for main:Object) after I’ve used search\_box helper in  
my view.

Adding include ActionView::Helpers::FormTagHelper to ERB string nor  
ApplicationHelper does not help.

How I should use helpers in this case?

–  
Witold R.  
[nhw.pl](http://nhw.pl/wp/) (EN blog)  
[NetManiac](http://nhw.pl/pl/) (PL blog)

---

<div class="post-metadata">

**Author:** ![viciu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@viciu](https://www.ruby-forum.com/u/viciu)\
**Post date:** [March 28, 2007, 5:05pm UTC](https://www.ruby-forum.com/t/accessing-helpers-in-applicationhelper/90414/2 "2007-03-28T17:05:11Z")

</div>

I would probably use a partial for this as this doesn’t seem abstract  
enough to be a helper. Will you use this form differently in more  
than one place?

To answer you’re exact question, I’m not sure that remote\_form\_tag is  
in FormTagHelper - it’s in PrototypeHelper. However, I would  
seriously consider using a partial as this helper could get real  
messy, real fast.

If you really do need to use a helper, I’d suggest having a look at  
the source code for the tag helpers and see how it’s handled by Rails.

Steve

---

<div class="post-metadata">

**Author:** ![viciu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/7ba0ec/32.png) [@viciu](https://www.ruby-forum.com/u/viciu)\
**Post date:** [March 28, 2007, 9:36pm UTC](https://www.ruby-forum.com/t/accessing-helpers-in-applicationhelper/90414/3 "2007-03-28T21:36:40Z")

</div>

Stephen B. wrote:

> I would probably use a partial for this as this doesn’t seem abstract  
> enough to be a helper. Will you use this form differently in more  
> than one place?  
> Well maybe this time I can use partial, but I think using partials could  
> also become messy (in my case), since with them I have to stick to  
> variable names. In search form this will be no problem, but in others  
> could be. Anyway, now I wonder how to use Rails helpers in custom helper  
> ;))

> To answer you’re exact question, I’m not sure that remote\_form\_tag is  
> in FormTagHelper - it’s in PrototypeHelper. However, I would  
> seriously consider using a partial as this helper could get real  
> messy, real fast.  
> Yes, exactly ProtypeHelper. I have tested with this include 😉

–  
Witold R.  
[nhw.pl](http://nhw.pl/wp/) (EN blog)  
[NetManiac](http://nhw.pl/pl/) (PL blog)
