Permalink
Browse files

Improve comment notifications in case of deletion

  • Loading branch information...
1 parent 38beaa2 commit a122cb01839ae677ebe8b78967c125b1da43d6be @robotmay committed Jan 28, 2014
Showing with 9 additions and 1 deletion.
  1. +5 −0 app/controllers/notifications_controller.rb
  2. +1 −1 app/models/comment.rb
  3. +3 −0 config/locales/en.yml
View
5 app/controllers/notifications_controller.rb
@@ -28,6 +28,11 @@ def show
respond_with @notification do |f|
f.html { redirect_to path }
end
+
+ rescue ActiveRecord::RecordNotFound
+ respond_to do |f|
+ f.html { redirect_to root_path, alert: t("notifications.not_found") }
+ end
end
def mark_all_as_read
View
2 app/models/comment.rb
@@ -1,7 +1,7 @@
class Comment < ActiveRecord::Base
belongs_to :user
belongs_to :comment_thread, touch: true
- has_many :notifications, as: :notifiable
+ has_many :notifications, as: :notifiable, dependent: :destroy
has_many :reports, as: :reportable
acts_as_tree dependent: :destroy
View
3 config/locales/en.yml
@@ -469,6 +469,9 @@ en:
title: "Notifications"
none: "You have no notifications right now."
mark_as_read: "Mark all as read"
+ not_found: >
+ That notification could not be found, it is possible that the event which
+ generated it has changed.
email:
subject: "Photographer.io: %{subject}"
button: "View on Photographer.io"

0 comments on commit a122cb0

Please sign in to comment.