just do it in the controller
This commit is contained in:
parent
7cf0ddc2ee
commit
ce72bde309
2 changed files with 7 additions and 9 deletions
|
@ -45,6 +45,13 @@ class MappingsController < ApplicationController
|
|||
@mapping = Mapping.find(params[:id])
|
||||
authorize @mapping
|
||||
|
||||
mappable = @mapping.mappable
|
||||
if mappable.defer_to_map
|
||||
mappable.permission = mappable.defer_to_map.permission
|
||||
mappable.defer_to_map_id = nil
|
||||
mappable.save
|
||||
end
|
||||
|
||||
@mapping.destroy
|
||||
|
||||
head :no_content
|
||||
|
|
|
@ -7,8 +7,6 @@ class Mapping < ActiveRecord::Base
|
|||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id", touch: true
|
||||
belongs_to :user
|
||||
|
||||
before_destroy :remove_defer
|
||||
|
||||
validates :xloc, presence: true,
|
||||
unless: Proc.new { |m| m.mappable_type == 'Synapse' }
|
||||
validates :yloc, presence: true,
|
||||
|
@ -28,11 +26,4 @@ class Mapping < ActiveRecord::Base
|
|||
super(:methods =>[:user_name, :user_image])
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def remove_defer(mapping)
|
||||
mappable = mapping.mappable
|
||||
mappable.defer_to_map_id = nil
|
||||
mappable.save
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue