I just discovered that assigning a ruby object to a javascript variable happens like this: (This is inside the html view)

var markers = <%= @buildings.to_json%>;

Now to access the name attr. of the building do:

markers.building.name

Thats all!

 
snippets.txt · Last modified: 2009/07/24 19:43 by typon
 
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki