Add a delete method for the user model.
authorTom Hughes <tom@compton.nu>
Tue, 25 Nov 2008 23:53:21 +0000 (23:53 +0000)
committerTom Hughes <tom@compton.nu>
Tue, 25 Nov 2008 23:53:21 +0000 (23:53 +0000)
app/models/user.rb

index 9b5bfd59528538f1826e6fc993a26eafb4c7301e..fae037110951ffe64d847fba40b99a0c37d40d9e 100644 (file)
@@ -104,4 +104,17 @@ class User < ActiveRecord::Base
     return false
   end
 
+  def delete
+    self.active = false
+    self.display_name = "user_#{self.id}"
+    self.description = nil
+    self.home_lat = nil
+    self.home_lon = nil
+    self.image = nil
+    self.email_valid = false
+    self.new_email = nil
+    self.visible = false
+    self.save
+  end
+
 end