繁体   English   中英

Rails Microposts显示全部

[英]Rails Microposts Show all

所以,按照M. Hartl的教程,我有这个static_pages控制器来显示它

class StaticPagesController < ApplicationController
def home
if signed_in?
  @micropost = current_user.microposts.build
  @feed_items = current_user.feed.paginate(page: params[:page])
end
end

def help
end

def about
end

def contact
end
end

这使得它在主页上显示所有当前用户的微博,但仅显示当前用户

我如何让它显示所有用户微博,每一个创建?

您正在查询查询以仅获取current_user微博。 Micropost.all应该为您提供所有微博。 还要确保您尚未在模型中设置一些默认范围,在这种情况下,您必须使用Micropost.unscoped

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM