"commented on your answer"
This commit is contained in:
parent
154c360e15
commit
43474a6c92
|
@ -5,4 +5,8 @@ class Comment < ActiveRecord::Base
|
||||||
validates :answer_id, presence: true
|
validates :answer_id, presence: true
|
||||||
|
|
||||||
validates :content, length: { maximum: 160 }
|
validates :content, length: { maximum: 160 }
|
||||||
|
|
||||||
|
def notification_type(*_args)
|
||||||
|
Notifications::Commented
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
class Notifications::Commented < Notification
|
||||||
|
end
|
|
@ -108,7 +108,8 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def comment(answer, content)
|
def comment(answer, content)
|
||||||
Comment.create!(user: self, answer: answer, content: content)
|
comment = Comment.create!(user: self, answer: answer, content: content)
|
||||||
|
Notification.notify answer.user, comment unless answer.user == self
|
||||||
increment! :commented_count
|
increment! :commented_count
|
||||||
answer.increment! :comment_count
|
answer.increment! :comment_count
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,16 +46,17 @@
|
||||||
ago
|
ago
|
||||||
.notification--icon
|
.notification--icon
|
||||||
%i.fa.fa-smile-o
|
%i.fa.fa-smile-o
|
||||||
%li.list-group-item
|
- when "Comment"
|
||||||
.media
|
.pull-left
|
||||||
.pull-left
|
%img.notification--img{src: gravatar_url(notification.target.user)}
|
||||||
%img.notification--img
|
.media-body
|
||||||
.media-body
|
%h6.media-heading.notification--user
|
||||||
%h6.media-heading.notification--user
|
= user_screen_name notification.target.user
|
||||||
username
|
%p.notification--text
|
||||||
%p.notification--text
|
commented on
|
||||||
commented
|
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)}
|
||||||
%a your answer
|
%a your answer
|
||||||
some time ago!
|
= time_ago_in_words notification.target.created_at
|
||||||
.notification--icon
|
ago
|
||||||
%i.fa.fa-comments
|
.notification--icon
|
||||||
|
%i.fa.fa-comments
|
Loading…
Reference in New Issue