diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 7a1406ea9..e95f1404a 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -128,7 +128,12 @@ class PhotosController < ApplicationController format.html do flash[:notice] = I18n.t 'photos.destroy.notice' if photo.status_message_guid - respond_with photo, :location => post_path(photo.status_message) + if photo.status_message.empty? + photo.status_message.destroy + respond_with photo, :location => person_photos_path(current_user.person) + else + respond_with photo, :location => post_path(photo.status_message) + end else respond_with photo, :location => person_photos_path(current_user.person) end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index c08386234..0db527a35 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -134,14 +134,19 @@ class StatusMessage < Post def comment_email_subject formatted_message(:plain_text => true) + end + + def empty? + self.text.blank? && self.photos == [] end protected def message_or_photos_present? - if self.text.blank? && self.photos == [] + if self.blank? errors[:base] << 'Status message requires a message or at least one photo' end end + end