From e481dcd822671cd563d1cb076766e767927533ac Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Mon, 7 Jan 2013 22:04:53 -0500 Subject: [PATCH] changed maps controller so it accepts synapses as a csv list --- app/controllers/maps_controller.rb | 32 +++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index 829f39fc..5ae51962 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -52,7 +52,7 @@ class MapsController < ApplicationController def create @user = current_user - @map = Map.new() + @map = Map.new() @map.name = params[:map][:name] @map.desc = params[:map][:desc] @map.permission = params[:map][:permission] @@ -61,11 +61,11 @@ class MapsController < ApplicationController @map.save if params[:map][:topicsToMap] - @all = params[:map][:topicsToMap] - @all = @all.split(',') - @all.each do |topic| - topic = topic.split('/') - @mapping = Mapping.new() + @all = params[:map][:topicsToMap] + @all = @all.split(',') + @all.each do |topic| + topic = topic.split('/') + @mapping = Mapping.new() @mapping.category = "Topic" @mapping.user = @user @mapping.map = @map @@ -73,8 +73,22 @@ class MapsController < ApplicationController @mapping.xloc = topic[1] @mapping.yloc = topic[2] @mapping.save - end - @map.arranged = true + end + + if params[:map][:synapsesToMap] + @synAll = params[:map][:synapsesToMap] + @synAll = @synAll.split(',') + @synAll.each do |synapse| + @mapping = Mapping.new() + @mapping.category = "Synapse" + @mapping.user = @user + @mapping.map = @map + @mapping.synapse = Synapse.find(synapse[0]) + @mapping.save + end + end + + @map.arranged = true @map.save respond_to do |format| format.js { respond_with(@map) } @@ -83,7 +97,7 @@ class MapsController < ApplicationController respond_to do |format| format.html { respond_with(@user, location: map_path(@map)) } end - end + end end # GET maps/:id/edit