# Using ERB inside a controller

**URL:** <https://www.ruby-forum.com/t/using-erb-inside-a-controller/135253>\
**Category:** Rails\
**Created:** [April 20, 2008, 12:49am UTC](https://www.ruby-forum.com/t/using-erb-inside-a-controller/135253 "2008-04-20T00:49:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 20, 2008, 12:49am UTC](https://www.ruby-forum.com/t/using-erb-inside-a-controller/135253/1 "2008-04-20T00:49:19Z")

</div>

I know it’s not desirable to use ERB inside the controller in theory,  
but I think I really need and I’m having problems.

I am using GMap the Google Map helper and all the coding for the  
markers (pop-ups) is done inside the controller. So often you do  
something like:

markers \<\< GMarker.new([obj.lat, obj.lng],  
:title =\> obj.name,  
:info\_window =\> “Bob’s House”,  
:icon =\> obj.gicon  
)

but instead of a boring plain text in the info\_window I wanted to use  
ajax links to dynamically update divs. Thus i would be nice to use  
e.g. link\_to\_remote and friends, but since that is in a view helper I  
can’t use can I? Must I resort to raw javascript?

---

<div class="post-metadata">

**Author:** ![Col\_W](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/dec6dc/32.png) [@Col\_W](https://www.ruby-forum.com/u/Col_W)\
**Post date:** [April 20, 2008, 12:32pm UTC](https://www.ruby-forum.com/t/using-erb-inside-a-controller/135253/2 "2008-04-20T12:32:25Z")

</div>

On 19 Apr 2008, at 23:48, Col W. wrote:

> ```
> :info_window => "Bob's House",
> :icon => obj.gicon
> )
> 
> ```
> 
> but instead of a boring plain text in the info\_window I wanted to use  
> ajax links to dynamically update divs. Thus i would be nice to use  
> e.g. link\_to\_remote and friends, but since that is in a view helper I  
> can’t use can I? Must I resort to raw javascript?  
> You can just include the relevant helper modules into your controller.  
> Slightly more clean is to have a helpers object into which you include  
> all those modules. You then have to say helpers.link\_to\_remote but you  
> don’t end up with dozens of methods added to your controller.

Fred
