Fix rubocop warning
[rails.git] / app / models / trace.rb
index af2c0af3bc1c4aa5cee88c446a83b885d129d1f2..7c97b4e96b64cc2c672ebafb9ebd4511b6a69dce 100644 (file)
@@ -43,12 +43,7 @@ class Trace < ActiveRecord::Base
   validates :timestamp, :presence => true
   validates :visibility, :inclusion => %w[private public trackable identifiable]
 
-  def destroy
-    super
-    FileUtils.rm_f(trace_name)
-    FileUtils.rm_f(icon_picture_name)
-    FileUtils.rm_f(large_picture_name)
-  end
+  after_destroy :remove_files
 
   def tagstring
     tags.collect(&:tag).join(", ")
@@ -343,4 +338,12 @@ class Trace < ActiveRecord::Base
 
     gpx
   end
+
+  private
+
+  def remove_files
+    FileUtils.rm_f(trace_name)
+    FileUtils.rm_f(icon_picture_name)
+    FileUtils.rm_f(large_picture_name)
+  end
 end