Files
nairobi/app/models/map_location.rb
Bertocq a44c830cd4 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.
2018-04-25 20:05:19 +02:00

22 lines
460 B
Ruby

class MapLocation < ActiveRecord::Base
belongs_to :proposal, touch: true
belongs_to :investment, class_name: Budget::Investment, touch: true
validates :longitude, :latitude, :zoom, presence: true, numericality: true
def available?
latitude.present? && longitude.present? && zoom.present?
end
def json_data
{
investment_id: investment_id,
proposal_id: proposal_id,
lat: latitude,
long: longitude
}
end
end