- Jan 2, 2006
- 10,455
- 35
- 91
I want a user to click on a pin on a map that's on my front page and the pin will have a message popup bubble with some data being displayed.
The pin itself is on a Pins table in PostgreSQL and has a unique pin_id and the pin JSON has an "activity" key.
The pin's pin_id is attached to a guide_id on a separate Guides table and that JSON has a "first_name" key. The Guides table displays a list of all guides (people who can show you around the area of the pin drop).
The console log of pinTitle is correct.
The console log of pinGuideFirstName comes back as undefined.
This is how I have my .RABL file set up:
When I go to the actual API URL (/api/pins) all the pins are displayed along with the pinGuideFirstName showing correctly.
Why is the first name showing up as undefined?
The pin itself is on a Pins table in PostgreSQL and has a unique pin_id and the pin JSON has an "activity" key.
The pin's pin_id is attached to a guide_id on a separate Guides table and that JSON has a "first_name" key. The Guides table displays a list of all guides (people who can show you around the area of the pin drop).
Code:
function getPinData(id, template) {
$.ajax({
url: "/api/pins/"+id,
type: "GET",
data: "JSON"
}).success(function(data){
var pinTitle = data["pin"]["activity"];
var pinGuideFirstName = data["pin"]["first_name"];
console.log("Pin Title: " + pinTitle);
console.log("Guide first name: " + pinGuideFirstName);
})
}
The console log of pinTitle is correct.
The console log of pinGuideFirstName comes back as undefined.
This is how I have my .RABL file set up:
Code:
collection @pins, root: :pins
attributes :id, :title
node :first_name do |pin|
pin.guide.user.first_name
end
When I go to the actual API URL (/api/pins) all the pins are displayed along with the pinGuideFirstName showing correctly.
Why is the first name showing up as undefined?