我不想列出每页的编号。我们怎样才能展示"之前"和" next"与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
答案 0 :(得分:3)
您是否在视图中尝试过此操作?
<%= will_paginate @activities, :page_links => false %>
从这里的文档(http://mislav.github.io/will_paginate/)看起来可能就是您要找的内容