Move current budget's geolocated investments code to helper function

This commit is contained in:
Bertocq
2018-01-18 01:40:58 +01:00
parent eeefa646a4
commit 304b3941a7
2 changed files with 13 additions and 2 deletions

View File

@@ -16,8 +16,7 @@ class BudgetsController < ApplicationController
def index
@budgets = @budgets.order(:created_at)
@budget = current_budget
budgets_map_locations = current_budget.investments.map{ |investment| investment.map_location }.compact
@budgets_coordinates = budgets_map_locations.map{ |ml| {lat: ml.latitude, long: ml.longitude, investment_title: ml.investment.title , investment_id: ml.investment.id, budget_id: ml.investment.budget.id}}
@budgets_coordinates = current_budget_map_locations
end
end