- has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id', :dependent => :destroy
- has_many :points, :class_name => 'Tracepoint', :foreign_key => 'gpx_id', :dependent => :destroy
+ has_many :tags, :class_name => 'Tracetag', :foreign_key => 'gpx_id', :dependent => :delete_all
+ has_many :points, :class_name => 'Tracepoint', :foreign_key => 'gpx_id', :dependent => :delete_all
+
+ def destroy
+ super
+ FileUtils.rm_f(trace_name)
+ FileUtils.rm_f(icon_picture_name)
+ FileUtils.rm_f(large_picture_name)
+ end
+
+ def tagstring
+ return tags.collect {|tt| tt.tag}.join(" ")
+ end