timeline now actually shows entries

This commit is contained in:
nilsding 2014-11-30 15:39:13 +01:00
parent 814a509f60
commit e8974415c9
2 changed files with 9 additions and 2 deletions

View File

@ -43,6 +43,11 @@ class User < ActiveRecord::Base
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.
def follow(target_user)
active_relationships.create(target: target_user)
@ -52,6 +57,7 @@ class User < ActiveRecord::Base
target_user.increment! :follower_count
end
# unfollows an user
def unfollow(target_user)
active_relationships.find_by(target: target_user).destroy

View File

@ -1,9 +1,10 @@
- if user_signed_in?
.container
%h1 Static#index
%h1 Timeline
= 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"
- else
.jumbotron