我的主页使用'public / index.html',它覆盖了我在这里阅读的所有内容。
因此,我已将所有已登录的用户重定向到我在路由中定义为http://localhost:3000/home
的{{1}}
我面临的问题是,在登录用户(/ home)的主页上,有分页。
当我尝试点击第2页get '/home' => 'static_pages#home', :as => :home
时,它会被发送到public / index.html。
我尝试使用链接http://localhost:3000/?page=2
作为测试,但它给了我一个空白的分页。没有显示任何项目。我该如何解决这个问题?
这是控制器
http://localhost:3000/home/?page=2
然后在我看来
class StaticPagesController < ApplicationController
def home
if signed_in?
@post = current_user.microposts.build
@activities = PublicActivity::Activity.order("created_at desc").paginate(page: params[:page])
@feed_items = current_user.feed.paginate(page: params[:page])
@items = @activities + @feed_items
@items.sort_by{|item| item.class == PublicActivity::Activity ? item.created_at : item.created_at}
@items = @items.paginate(:page => 1, :per_page => 10)
else
redirect_to root_path
end
end
这是_item.html.erb部分
<%= render partial: 'shared/item', collection: @items %>
<%= will_paginate @items %>