when topic or synapse is no longer on a map, don't defer
This commit is contained in:
parent
b2da15245a
commit
5928969724
1 changed files with 9 additions and 0 deletions
|
@ -7,6 +7,8 @@ class Mapping < ActiveRecord::Base
|
||||||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id", touch: true
|
belongs_to :map, :class_name => "Map", :foreign_key => "map_id", touch: true
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
|
after_destroy :remove_defer
|
||||||
|
|
||||||
validates :xloc, presence: true,
|
validates :xloc, presence: true,
|
||||||
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
|
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
|
||||||
validates :yloc, presence: true,
|
validates :yloc, presence: true,
|
||||||
|
@ -26,4 +28,11 @@ class Mapping < ActiveRecord::Base
|
||||||
super(:methods =>[:user_name, :user_image])
|
super(:methods =>[:user_name, :user_image])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def remove_defer(mapping)
|
||||||
|
mappable = mapping.mappable
|
||||||
|
mappable.defer_to_map_id = nil
|
||||||
|
mappable.save
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue