"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 :content, length: { maximum: 160 }
|
||||
|
||||
def notification_type(*_args)
|
||||
Notifications::Commented
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
class Notifications::Commented < Notification
|
||||
end
|
|
@ -108,7 +108,8 @@ class User < ActiveRecord::Base
|
|||
end
|
||||
|
||||
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
|
||||
answer.increment! :comment_count
|
||||
end
|
||||
|
|
|
@ -46,16 +46,17 @@
|
|||
ago
|
||||
.notification--icon
|
||||
%i.fa.fa-smile-o
|
||||
%li.list-group-item
|
||||
.media
|
||||
- when "Comment"
|
||||
.pull-left
|
||||
%img.notification--img
|
||||
%img.notification--img{src: gravatar_url(notification.target.user)}
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
username
|
||||
= user_screen_name notification.target.user
|
||||
%p.notification--text
|
||||
commented
|
||||
commented on
|
||||
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)}
|
||||
%a your answer
|
||||
some time ago!
|
||||
= time_ago_in_words notification.target.created_at
|
||||
ago
|
||||
.notification--icon
|
||||
%i.fa.fa-comments
|
Loading…
Reference in New Issue