0
所以,以下M.哈特爾的教程,我有這個static_pages控制器,顯示此Rails的微柱顯示所有
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
,這使得它顯示在主頁上,當前所有的用戶微觀柱,但只當前用戶
我該如何讓它顯示所有用戶micropost,每一個創建的?
so @feed_items = Micropost.all.feed.paginate(page:params [:page]) ?? – PMP 2013-04-20 14:23:09
在你的問題中,我看到飼料與用戶有關,但上面的評論顯示了Micropost和飼料之間的關係。你可以發佈User,microposts和feed之間的關係嗎?如果您定義了適當的方法將返回Micropost數組的所有提要,Micropost.all.feed將起作用。 – 2013-04-20 14:25:58
我不關注 你究竟需要我上傳 – PMP 2013-04-20 14:31:56