AnthonyGalli.com
AnthonyGalli.com

Reputation: 2866

will_paginate only show previous_page & next_page?

I don't want to list out the number of each page. How can we just show "previous" and "next" with will_paginate?

view

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

controller

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

model

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

Upvotes: 1

Views: 1407

Answers (1)

Chris
Chris

Reputation: 388

Have you tried this in your view?

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

From the docs here ( http://mislav.github.io/will_paginate/ ) it looks like that might be what you're looking for

Upvotes: 4

Related Questions