]> git.openstreetmap.org Git - rails.git/commitdiff
Fix rubocop warning
authorTom Hughes <tom@compton.nu>
Wed, 5 Jun 2019 08:20:00 +0000 (09:20 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 5 Jun 2019 08:20:00 +0000 (09:20 +0100)
.rubocop_todo.yml
app/models/trace.rb

index 342275040340ab172c334d9313e2d769e7eb3dfa..76a4cada2052e0d329e4dd2620795e173206ed6b 100644 (file)
@@ -100,13 +100,6 @@ Naming/PredicateName:
     - 'app/models/user.rb'
     - 'lib/classic_pagination/pagination.rb'
 
-# Offense count: 1
-# Configuration parameters: Include.
-# Include: app/models/**/*.rb
-Rails/ActiveRecordOverride:
-  Exclude:
-    - 'app/models/trace.rb'
-
 # Offense count: 6
 # Configuration parameters: Database, Include.
 # SupportedDatabases: mysql, postgresql
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