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.
22 lines
460 B
Ruby
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
|