diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb index 03f928ce..f5880dd9 100644 --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -153,18 +153,7 @@ class MainController < ApplicationController if term && !term.empty? @synapses = policy_scope(Synapse).where('LOWER("desc") like ?', '%' + term.downcase + '%').order('"desc"') - # remove any duplicate synapse types that just differ by - # leading or trailing whitespaces - collectedDesc = [] - @synapses.to_a.uniq(&:desc).delete_if do |s| - desc = s.desc.nil? || s.desc == '' ? '' : s.desc.strip - if collectedDesc.index(desc).nil? - collectedDesc.push(desc) - false # return this value - else - true # return this value - end - end + @synapses = @synapses.uniq(&:desc) elsif topic1id && !topic1id.empty? @one = policy_scope(Synapse).where('node1_id = ? AND node2_id = ?', topic1id, topic2id) @two = policy_scope(Synapse).where('node2_id = ? AND node1_id = ?', topic1id, topic2id) diff --git a/app/controllers/synapses_controller.rb b/app/controllers/synapses_controller.rb index 310e48cd..ddb3e5ab 100644 --- a/app/controllers/synapses_controller.rb +++ b/app/controllers/synapses_controller.rb @@ -20,6 +20,7 @@ class SynapsesController < ApplicationController def create @synapse = Synapse.new(synapse_params) @synapse.desc = '' if @synapse.desc.nil? + @synapse.desc.strip! # no trailing/leading whitespace authorize @synapse respond_to do |format|