diff options
author | Francis Irving <francis@mysociety.org> | 2010-07-15 14:32:05 +0100 |
---|---|---|
committer | Francis Irving <francis@mysociety.org> | 2010-07-15 14:32:05 +0100 |
commit | 3ecbcf1abd036965740813583302ac9c344b8b7a (patch) | |
tree | da36354c367a6985f9b3b1fb39b360b5d84f99a5 /app/models/user.rb | |
parent | 2b91bbb4db04b6f3935478a3f6e8a0fe61fc06fb (diff) |
Get key dependency right. Test for draft pictures.
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 11 |
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 |