Using JSON input in Ruby method on Rails

Posted by Zachary on Stack Overflow See other posts from Stack Overflow or by Zachary
Published on 2010-03-28T16:51:59Z Indexed on 2010/03/28 16:53 UTC
Read the original article Hit count: 519

Filed under:
|
|
|
|

I am using jQuery to make an AJAX call to a ruby method in my controller. The javascript looks something like this:

    var latLongJSON =
    {
        "address": [
        {"lat" : 50,
        "long" : 50} ]
    };

    var returnedAddresses;

    $.ajax({
        type: "GET",
        data: latLongJSON,
        url: "map/getaddresses",
        success: function(data) {
            returnedAddresses = JSON.parse(data);
        }
    });

Then in my 'getaddresses' method, my parameter coming through looks like:

Parameters: {"address"=>"[object Object]"}

I'm not sure what to do with this. I'm fairly new to Ruby, and I'm not sure if I need to convert this to something else, or what. Ideally I want to be able to pass in multiple sets of lat/long in the 'address' array, then be able to iterate over those in my Ruby code.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about ruby