Forum: Ruby on Rails Help with MySQL Select, Update and Ajax.Request/Updater

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bc6edb812f235f5c19519c213b1a65b0?d=identicon&s=25 Taz Singh (tazsingh)
on 2007-05-28 01:22

I am fairly new to Rails but I have done a lot of stuff in PHP. I'm not
sure why this isn't working, but I have tried a lot of ways to do the
same thing. Please let me know what you think.

What I'm trying to do is integrate Google Maps into a Rails. Basically,
when a user moves a marker, an Ajax.Request/Updater (for debugging
purposes) is sent to my controller. However, the code in my controller
is not doing what it should be doing. I want it to Select the old row
and Update it with the new information. Here is my code:

  def setmarker
    usr_marker = Marker.find(:all, :conditions => "latitude =
'#{params[:oldLat]}' AND longitude = '#{params[:oldLng]}'")
    Marker.update(, {:latitude => params[:newLat],
:longitude => params[:newLng]})
    render_text usr_marker.latitude

Ajax.Updater (for debugging purposes... switching back to Ajax.Request
new Ajax.Updater("content", "/members_home/setmarker", {
    method: 'post',
    parameters: "oldLat=" + + "&oldLng=" +
oldLatLng.lng() + "&newLat=" + marker.getPoint().lat() + "&newLng=" +
    insertion: Insertion.Bottom

The Ajax stuff works as it should, here's a bit of the error which I am
Parameters: {"oldLng"=>"-79.6903", "newLng"=>"-79.74494934082031",
"oldLat"=>"43.4667", "newLat"=>"43.47733866178997"}

And I am having multiple errors, but the one I am having right now is
ActiveRecord::RecordNotFound when the record should definately be there.

Thanks in advance!
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 MichaelLatta (Guest)
on 2007-05-28 02:49
(Received via mailing list)
For one thing find(:all, ...) can return multiple rows so the result
is an array.

I would suggest that rather than using Marker.update on the class that
you simply update the objects returned from find.  After changing the
attributes you wish to update, just call save on the modified objects.


On May 27, 4:22 pm, Taz Singh <>
This topic is locked and can not be replied to.