Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Lambda Calculus <code@thelambdacalculus.net>2011-09-13 11:04:22 +0400
committerThe Lambda Calculus <code@thelambdacalculus.net>2011-09-13 11:04:22 +0400
commitf8f1ef3f91fb237f54b45dd35fd408f749f90513 (patch)
tree16c0d0dc84f2861614e5a3f3da0339635f9b6315 /app/models/photo.rb
parent2947ee46f4950b3777f78ca54275eb9527143a72 (diff)
Refactored code so that the controller got thinner while the model become fatter [Finishes #1126]
Diffstat (limited to 'app/models/photo.rb')
-rw-r--r--app/models/photo.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/photo.rb b/app/models/photo.rb
index 0f8118257..cdebd3f2a 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -19,8 +19,17 @@ class Photo < Post
validate :ownership_of_status_message
before_destroy :ensure_user_picture
+ after_destroy :clear_empty_status_message
after_create :queue_processing_job
+ def clear_empty_status_message
+ if self.status_message_guid && self.status_message.text_and_photos_blank?
+ self.status_message.destroy
+ else
+ true
+ end
+ end
+
def ownership_of_status_message
message = StatusMessage.find_by_guid(self.status_message_guid)
if self.status_message_guid && message