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 }) }
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