Cleaned and optimized report model
This commit is contained in:
parent
0fae1137fa
commit
6309e1a4ee
1 changed files with 2 additions and 4 deletions
|
|
@ -10,7 +10,7 @@ class Report < ActiveRecord::Base
|
|||
belongs_to :post
|
||||
belongs_to :comment
|
||||
|
||||
after_create :send_report_notification
|
||||
after_commit :send_report_notification, :on => :create
|
||||
|
||||
def entry_exists
|
||||
if Report.where(post_id: post_id, post_type: post_type).exists?(user_id: user_id)
|
||||
|
|
@ -50,9 +50,7 @@ class Report < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def mark_as_reviewed
|
||||
if reports = Report.where(post_id: post_id, post_type: post_type)
|
||||
reports.update_all(reviewed: true)
|
||||
end
|
||||
Report.where(post_id: post_id, post_type: post_type).update_all(reviewed: true)
|
||||
end
|
||||
|
||||
def send_report_notification
|
||||
|
|
|
|||
Loading…
Reference in a new issue