Merge pull request #2295 from wairbut-m2c/aperez-mappable-objects

Improvements for Mappable objects
This commit is contained in:
BertoCQ
2018-02-02 19:26:47 +01:00
committed by GitHub
7 changed files with 57 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ module Mappable
attr_accessor :skip_map
has_one :map_location, dependent: :destroy
accepts_nested_attributes_for :map_location, allow_destroy: true
accepts_nested_attributes_for :map_location, allow_destroy: true, reject_if: :all_blank
validate :map_must_be_valid, on: :create, if: :feature_maps?

View File

@@ -3,6 +3,8 @@ class MapLocation < ActiveRecord::Base
belongs_to :proposal, touch: true
belongs_to :investment, class_name: Budget::Investment, touch: true
validates :longitude, :latitude, :zoom, presence: true
def available?
latitude.present? && longitude.present? && zoom.present?
end