From a44c830cd4473925bd12edbeb26d93bb86baa01a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 25 Apr 2018 19:18:18 +0200 Subject: [PATCH] Fix MapLocation json_data to return mappable ids Until we correctly make MapLocation relation with mappables a polymorphic one... we'll need to return the investment_id and proposal_id values. Right now it was returning the MapLocation ID, and the JS was making a call searching for an Investment with the MapLocation ID... sometimes finding a record with same ID but totally NOT the one associated to the MapLocation. --- app/assets/javascripts/map.js.coffee | 2 +- app/models/map_location.rb | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/map.js.coffee b/app/assets/javascripts/map.js.coffee index e70a65f4c..ef2c27e28 100644 --- a/app/assets/javascripts/map.js.coffee +++ b/app/assets/javascripts/map.js.coffee @@ -99,7 +99,7 @@ App.Map = for i in addMarkerInvestments if App.Map.validCoordinates(i) marker = createMarker(i.lat, i.long) - marker.options['id'] = i.id + marker.options['id'] = i.investment_id marker.on 'click', openMarkerPopup diff --git a/app/models/map_location.rb b/app/models/map_location.rb index 590eeb284..f66d71e34 100644 --- a/app/models/map_location.rb +++ b/app/models/map_location.rb @@ -11,7 +11,8 @@ class MapLocation < ActiveRecord::Base def json_data { - id: id, + investment_id: investment_id, + proposal_id: proposal_id, lat: latitude, long: longitude }