Add map_location#json_data method
This commit is contained in:
@@ -65,15 +65,6 @@ module BudgetsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_budget_map_locations
|
def current_budget_map_locations
|
||||||
current_budget.investments.map do |investment|
|
MapLocation.where(investment_id: current_budget.investments).map { |l| l.json_data }
|
||||||
next unless investment.map_location.present?
|
|
||||||
{
|
|
||||||
lat: investment.map_location.latitude,
|
|
||||||
long: investment.map_location.longitude,
|
|
||||||
investment_title: investment.title,
|
|
||||||
investment_id: investment.id,
|
|
||||||
budget_id: current_budget.id
|
|
||||||
}
|
|
||||||
end.flatten.compact
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,4 +9,12 @@ class MapLocation < ActiveRecord::Base
|
|||||||
latitude.present? && longitude.present? && zoom.present?
|
latitude.present? && longitude.present? && zoom.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def json_data
|
||||||
|
{
|
||||||
|
id: id,
|
||||||
|
lat: latitude,
|
||||||
|
long: longitude
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user