# Rails code in a Javascript function

**URL:** <https://www.ruby-forum.com/t/rails-code-in-a-javascript-function/121965>\
**Category:** Rails\
**Created:** [December 3, 2007, 2:16pm UTC](https://www.ruby-forum.com/t/rails-code-in-a-javascript-function/121965 "2007-12-03T14:16:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![serkan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b5ac83/32.png) [@serkan](https://www.ruby-forum.com/u/serkan)\
**Post date:** [December 3, 2007, 2:16pm UTC](https://www.ruby-forum.com/t/rails-code-in-a-javascript-function/121965/1 "2007-12-03T14:16:27Z")

</div>

Hi guys!

In Rails, can you stick Rails code in a javascript function? An example,  
this code from the Geokit plugin on a view page which doesnt work for  
me:

```
    function initialize() {
        var map = new GMap(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.centerAndZoom(new GPoint(-122.443882, 37.769079), 5);

        <removed_email_address@domain.invalid do |place|%>
        var point = new

```

GPoint(\<%=place[:longitude]%\>,\<%=place[:latitude]%\>);  
var marker = createMarker(point,’

\<%=h  
place[:description]%\>
’)  
map.addOverlay(marker);  
\<%end%\>  
}

Any help would be appreciated!

cheers!
