Updating Google Map Using YM4R plugin link_to issue
I have my map working and displaying correctly. I trying to get it to update but I am running into issues.
From What I have gotten from searching on the web it seems to be easy to implement.
In my co开发者_开发知识库ntroller in the update I have
def update
@map = Variable.new("map")
@marker = GMarker.new([75.89,-42.767],:title => "Update", :info_window => "I have been placed through RJS")
end
In my update.rjs I have
page << @map.clear_overlays
page << @map.add_overlay(@marker)
In html.erb I am trying to set a link to this and I currently have the follow
<%=link_to "update", google_map_path(@google_map),:remote => true %>
The problem is for sure in the google_map_path(@google_map). My url to the update is wrong I am pretty sure resulting in the map not updating when I give it a new latitude and longitude.
Since it is an update method, perhaps the link should include a method something like this?
<%=link_to "update", google_map_path(@google_map), :method => :put, :remote => true %>
What does the route look like?
Hi... I'm just updating this with an example from one of my projects. I'm not sure this will be any help at all, but at least you'll see what is expected. I have an rsvp controller.
In config/routes.rb I have this
resources :rsvps
In my view I have this:
<%=link_to "update", rsvp_path(@rsvp), :method => :put, :remote => true %>
And this is the HTML that is rendered.
<a rel="nofollow" data-remote="true" data-method="put" href="/rsvps/4">update</a>
If you are getting an error about it finding the route, double check the name of the route that you want to use and make sure it is correct.
You can also test by manually entering the path with something like this:
<%=link_to "update", "/rsvps/#{@rsvp.id}", :method => :put, :remote => true %>
Once you get it to render the correct anchor to the page, then you can start trouble shooting the javascript for the ajax request.
Good luck.
精彩评论