"followed you"
This commit is contained in:
parent
c56177cd10
commit
c9b5947e6b
|
@ -0,0 +1,2 @@
|
|||
class Notifications::StartedFollowing < Notification
|
||||
end
|
|
@ -3,4 +3,8 @@ class Relationship < ActiveRecord::Base
|
|||
belongs_to :target, class_name: 'User'
|
||||
validates :source_id, presence: true
|
||||
validates :target_id, presence: true
|
||||
|
||||
def notification_type(*_args)
|
||||
Notifications::StartedFollowing
|
||||
end
|
||||
end
|
||||
|
|
|
@ -56,7 +56,8 @@ class User < ActiveRecord::Base
|
|||
|
||||
# follows an user.
|
||||
def follow(target_user)
|
||||
active_relationships.create(target: target_user)
|
||||
relationship = active_relationships.create(target: target_user)
|
||||
Notification.notify target_user, relationship
|
||||
|
||||
# increment counts
|
||||
increment! :friend_count
|
||||
|
|
|
@ -5,13 +5,13 @@
|
|||
- Notification.for(current_user).each do |notification|
|
||||
%li.list-group-item
|
||||
.media
|
||||
- case notification.target_type
|
||||
- when "Answer"
|
||||
.pull-left
|
||||
%img.notification--img{src: gravatar_url(notification.target.user)}
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
= user_screen_name notification.target.user
|
||||
- case notification.target_type
|
||||
- when "Answer"
|
||||
%p.notification--text
|
||||
answered
|
||||
%a{href: show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id)}
|
||||
|
@ -20,13 +20,12 @@
|
|||
ago
|
||||
.notification--icon
|
||||
%i.fa.fa-exclamation
|
||||
%li.list-group-item
|
||||
.media
|
||||
- when "Relationship"
|
||||
.pull-left
|
||||
%img.notification--img
|
||||
%img.notification--img{src: gravatar_url(notification.target.source)}
|
||||
.media-body
|
||||
%h6.media-heading.notification--user
|
||||
username
|
||||
= user_screen_name notification.target.source
|
||||
%p.notification--text
|
||||
followed you!
|
||||
.notification--icon
|
||||
|
|
Loading…
Reference in New Issue