• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

davidcelis / api-pagination / 45
99%

Build:
DEFAULT BRANCH: master
Ran 10 Apr 2014 09:53PM UTC
Jobs 6
Files 11
Run time 16min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
45

push

travis-ci

davidcelis
Change interface for Rails pagination

This fixes #7 but is also related to a more dire issue. `after_filter`
was misunderstood to provide access to the response before the body had
been written. In actuality, the response has already been fully
constructed by the time `after_filter` is called, which means that the
collection has already been queried and written as json (or XML). In
order to maintain a nice interface without using after_filter, the
method signature of `paginate` has changed to act like `render`:

```rails
class API::v1::PostsController < ApplicationController
  def index
    # Uncomment this line to change the default per_page from 10 to 25:
    # params[:per_page] ||= 25
    posts = Post.all

    paginate json: posts
  end
end
```

At the end, `paginate` simply passes its arguments on to `render` so all
of `render's` options are supported. The collection is assumed to live
either in the argument hash's `:json` key or an `:xml` key.

Signed-off-by: David Celis <me@davidcel.is>

224 of 227 relevant lines covered (98.68%)

44.93 hits per line

Jobs
ID Job ID Ran Files Coverage
1 45.1 (1.9.3, PAGINATOR=kaminari) 10 Apr 2014 09:53PM UTC 0
97.8
Travis Job 45.1
2 45.2 (1.9.3, PAGINATOR=will_paginate) 10 Apr 2014 09:53PM UTC 0
97.36
Travis Job 45.2
3 45.3 (2.0.0, PAGINATOR=kaminari) 10 Apr 2014 09:54PM UTC 0
97.8
Travis Job 45.3
4 45.4 (2.0.0, PAGINATOR=will_paginate) 10 Apr 2014 09:53PM UTC 0
97.36
Travis Job 45.4
5 45.5 (2.1.0, PAGINATOR=kaminari) 10 Apr 2014 09:53PM UTC 0
97.8
Travis Job 45.5
6 45.6 (2.1.0, PAGINATOR=will_paginate) 10 Apr 2014 10:09PM UTC 0
97.36
Travis Job 45.6
Source Files on build 45
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #45
  • 81ec7027 on github
  • Prev Build on master (#44)
  • Next Build on master (#46)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc