timeline now actually shows entries
This commit is contained in:
parent
814a509f60
commit
e8974415c9
|
@ -43,6 +43,11 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Array] the users' timeline
|
||||||
|
def timeline
|
||||||
|
Answer.where("user_id in (?) OR user_id = ?", friend_ids, id).order(:created_at).reverse_order
|
||||||
|
end
|
||||||
|
|
||||||
# follows an user.
|
# follows an user.
|
||||||
def follow(target_user)
|
def follow(target_user)
|
||||||
active_relationships.create(target: target_user)
|
active_relationships.create(target: target_user)
|
||||||
|
@ -52,6 +57,7 @@ class User < ActiveRecord::Base
|
||||||
target_user.increment! :follower_count
|
target_user.increment! :follower_count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# unfollows an user
|
||||||
def unfollow(target_user)
|
def unfollow(target_user)
|
||||||
active_relationships.find_by(target: target_user).destroy
|
active_relationships.find_by(target: target_user).destroy
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
.container
|
.container
|
||||||
%h1 Static#index
|
%h1 Timeline
|
||||||
= render 'layouts/messages'
|
= render 'layouts/messages'
|
||||||
|
|
||||||
%p Find me in app/views/static/index.html.haml
|
- current_user.timeline.each do |answer|
|
||||||
|
= render 'shared/answerbox', a: answer
|
||||||
= render "shared/links"
|
= render "shared/links"
|
||||||
- else
|
- else
|
||||||
.jumbotron
|
.jumbotron
|
||||||
|
|
Loading…
Reference in New Issue