rails tutorial, feed with all users
I'm doing the rails tutorial and in it we make a feed like twitter with your own posts and following others. I wanted to know how I could take this feed an incl开发者_如何学Goude all posts on the home page and only the specific user's on their page. Right now I can see my own tweets and those I'm following on the home page and then the same on my profile page. I want my profile page to stay the same with only my own posts but I want the home page to render all posts from all users.
My home page code is like so
<td class="micropost">
<span class="user">
<%= link_to feed_item.user.name, feed_item.user %>
</span>
<span class="content"><%= feed_item.content %></span>
<span class="timestamp">
Posted <%= time_ago_in_words(feed_item.created_at) %> ago.
</span>
</td>
<% if current_user?(feed_item.user) %>
My Micropost Controller:
'before_filter :authenticate, :only => [:create, :destroy]
before_filter :authorized_user, :only => :destroy
def create @micropost = current_user.microposts.build(params[:micropost]) if @micropost.save flash[:success] = "Micropost created!" redirect_to root_path else @feed_items = [] render 'pages/home' end end'
my Pages controller:
class PagesController < ApplicationController
def home @title = "Home" if signed_in? @micropost = Micropost.new @feed_items = current_user.feed.paginate(:page => params[:page]) end end
if somebody could help me or point me in the right direction that would be great. I'm sorry if I asked this question the wrong away or in the wrong format I'm a noob at this and looking it up online hasn't really helped me and I was recommended stackoverflow. Thanks.
What is the beginning of the block of code in your view? Something that looks like:
<% users.feed each do |user| %>
Also, what is the code like on your profile page?
精彩评论