aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb11
1 files changed, 2 insertions, 9 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 00fd332ad..7af3ad2d3 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -277,19 +277,12 @@ class User < ActiveRecord::Base
# A photograph of the user (to make it all more human)
def set_profile_photo(new_profile_photo)
- old_profile_photo = nil
ActiveRecord::Base.transaction do
if !self.profile_photo.nil?
- old_profile_photo = self.profile_photo
- self.profile_photo = nil
+ self.profile_photo.destroy
end
self.profile_photo = new_profile_photo
- end
- if !old_profile_photo.nil?
- # This doesn't work in the transaction, as destroy starts
- # a new transaction immediately (the database foreign key
- # constraint detects it). Yuck.
- old_profile_photo.destroy
+ self.save
end
end