Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

gmaps4rails dynamic load question


Trying to modify the screencast to be unobtrusive. Have an action (updatemap) that completes the following query:

 @markers = Location.active.all.to_gmaps4rails

Then in updatemap.js.erb:

Gmaps4Rails.replace_markers(?);

With it empty the markers clear so I know that works but can't figure the proper syntax to go between the parenthesis to display the new markers.

@markers, is stored in JSON format but how do get them to be entered, tried <%= @markers %> but that failed.


Solution

  • You should declare the json as safe or render it raw:

    Gmaps4Rails(<%=raw @markers %>);