gpt4 book ai didi

ruby-on-rails - will_paginate 只显示上一页和下一页?

转载 作者:太空宇宙 更新时间:2023-11-03 18:08:56 24 4
gpt4 key购买 nike

我不想列出每页的编号。我们如何才能使用 will_paginate 显示“上一个”和“下一个”?

查看

<%= will_paginate @activities %>
<% @activities.each do |activity| %>
etc...
<% end %>

控制者

class ActivitiesController < ApplicationController
def index
@activities = Activity.order("created_at desc").where(user_id: current_user.following_ids).paginate(:page => params[:page])
end
end

型号

class Activity < ActiveRecord::Base
self.per_page = 25

def page_number
(index / per_page.to_f).ceil
end

private

def index
Activity.order(created_at: :desc).index self
end
end

最佳答案

在您看来,您尝试过吗?

<%= will_paginate @activities, :page_links => false %>

从此处的文档 (http://mislav.github.io/will_paginate/) 看来,这可能就是您正在寻找的内容

关于ruby-on-rails - will_paginate 只显示上一页和下一页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38133790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com