fix map forking (fix #540)

This commit is contained in:
Devin Howard 2016-04-20 08:51:38 +08:00
parent 7bb7f345f1
commit 837e4bde1b

View file

@ -158,35 +158,34 @@ class MapsController < ApplicationController
@map.arranged = false @map.arranged = false
if params[:topicsToMap] if params[:topicsToMap]
@all = params[:topicsToMap] @all = params[:topicsToMap]
@all = @all.split(',') @all = @all.split(',')
@all.each do |topic| @all.each do |topic|
topic = topic.split('/') topic = topic.split('/')
mapping = Mapping.new() mapping = Mapping.new
mapping.user = @user mapping.map = @map
mapping.mappable = Topic.find(topic[0]) mapping.user = @user
mapping.xloc = topic[1] mapping.mappable = Topic.find(topic[0])
mapping.yloc = topic[2] mapping.xloc = topic[1]
@map.topicmappings << mapping mapping.yloc = topic[2]
authorize mapping, :create authorize mapping, :create?
mapping.save mapping.save
end end
if params[:synapsesToMap] if params[:synapsesToMap]
@synAll = params[:synapsesToMap] @synAll = params[:synapsesToMap]
@synAll = @synAll.split(',') @synAll = @synAll.split(',')
@synAll.each do |synapse_id| @synAll.each do |synapse_id|
mapping = Mapping.new() mapping = Mapping.new
mapping.user = @user mapping.map = @map
mapping.map = @map mapping.user = @user
mapping.mappable = Synapse.find(synapse_id) mapping.mappable = Synapse.find(synapse_id)
@map.synapsemappings << mapping authorize mapping, :create?
authorize mapping, :create mapping.save
mapping.save
end
end end
end
@map.arranged = true @map.arranged = true
end end
authorize @map authorize @map