Skip to content

Added pagination#182

Open
eelcoj wants to merge 1 commit intomainfrom
pagination
Open

Added pagination#182
eelcoj wants to merge 1 commit intomainfrom
pagination

Conversation

@eelcoj
Copy link
Copy Markdown
Contributor

@eelcoj eelcoj commented Apr 6, 2026

Usage:

class Content::Post < Perron::Resource
  configure do |config|
    config.pagination.per_page = 10
  end
end
class Content::PostsController < ApplicationController
  include Perron::PaginateHelper

  def index
    @paginate, @resources = paginate(Content::Post, Content::Post.all)
  end
end
<%# app/views/content/posts/index.html.erb %>
<%= link_to "Previous", @paginate.previous if @paginate.previous? %>
<%= link_to "Next", @paginate.next if @paginate.next? %>

Not 100% happy with the API yet—but pretty close for basic pagination. This design should also make it easy to extend with “pagination groupings”, eg. by year/month/day.

Closes #63

Usage:

```
class Content::Post < Perron::Resource
  configure do |config|
    config.pagination.per_page = 10
  end
end
```
```
class Content::PostsController < ApplicationController
  include Perron::PaginateHelper

  def index
    @paginate, @resources = paginate(Content::Post, Content::Post.all)
  end
end
```

```
<%# app/views/content/posts/index.html.erb %>
<%= link_to "Previous", @paginate.previous if @paginate.previous? %>
<%= link_to "Next", @paginate.next if @paginate.next? %>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pagination

1 participant