]> git.openstreetmap.org Git - rails.git/blobdiff - app/models/trace.rb
Remove SotM 2022 banner, add fundraising banner
[rails.git] / app / models / trace.rb
index 957bea8bc043429b5df7c72e3b0c97c55a86d87e..35fee0bf4f800d7fd22f906d1b9cc3040ea5727f 100644 (file)
@@ -35,7 +35,7 @@ class Trace < ApplicationRecord
   has_many :points, :class_name => "Tracepoint", :foreign_key => "gpx_id", :dependent => :delete_all, :inverse_of => :trace
 
   scope :visible, -> { where(:visible => true) }
-  scope :visible_to, ->(u) { visible.where("visibility IN ('public', 'identifiable') OR user_id = ?", u) }
+  scope :visible_to, ->(u) { visible.where(:visibility => %w[public identifiable]).or(visible.where(:user => u)) }
   scope :visible_to_all, -> { where(:visibility => %w[public identifiable]) }
   scope :tagged, ->(t) { joins(:tags).where(:gpx_file_tags => { :tag => t }) }
 
@@ -57,7 +57,7 @@ class Trace < ApplicationRecord
 
   def tagstring=(s)
     self.tags = if s.include? ","
-                  s.split(/\s*,\s*/).grep_v(/^\s*$/).collect do |tag|
+                  s.split(",").map(&:strip).reject(&:empty?).collect do |tag|
                     tt = Tracetag.new
                     tt.tag = tag
                     tt