Location and entry maps

used MapBox Api to generate map on location show page.  
--map displays marker for each entry near the map center.
--javascript is in the html file.  I was having trouble getting the ruby variables to work in a seperate js.erb file.  Help would be appreciated.
I had a lot of trouble getting it to work in another file.  I put <%@location%> in the js.erb file, and call <%@location.nearby_entries%> but it whenever I'd open the page I would get a 'no method for nil' error.