From 96871cadab1a0e9b6d5d931fdfe5f65fe737405e Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 23 Oct 2015 22:10:45 +0800 Subject: [PATCH] brute force prevent nil synapse descriptions --- app/assets/javascripts/src/Metamaps.js | 2 +- app/controllers/synapses_controller.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index 1e284a6b..aea20ab9 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -4282,7 +4282,7 @@ Metamaps.Synapse = { node1 = synapsesToCreate[i]; topic1 = node1.getData('topic'); synapse = new Metamaps.Backbone.Synapse({ - desc: Metamaps.Create.newSynapse.description, + desc: Metamaps.Create.newSynapse.description || "", node1_id: topic1.isNew() ? topic1.cid : topic1.id, node2_id: topic2.isNew() ? topic2.cid : topic2.id, }); diff --git a/app/controllers/synapses_controller.rb b/app/controllers/synapses_controller.rb index 47d3321e..dc36ff28 100644 --- a/app/controllers/synapses_controller.rb +++ b/app/controllers/synapses_controller.rb @@ -22,6 +22,7 @@ class SynapsesController < ApplicationController # POST /synapses.json def create @synapse = Synapse.new(synapse_params) + @synapse.update_attribute :desc, "" if @synapse.desc.nil? respond_to do |format| if @synapse.save @@ -36,6 +37,7 @@ class SynapsesController < ApplicationController # PUT /synapses/1.json def update @synapse = Synapse.find(params[:id]) + @synapse.update_attribute :desc, "" if @synapse.desc.nil? respond_to do |format| if @synapse.update_attributes(synapse_params)