mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-22 22:06:50 +00:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
1e47c167a1
10
.travis.yml
10
.travis.yml
@ -7,12 +7,16 @@ rvm:
|
|||||||
- 2.2.6
|
- 2.2.6
|
||||||
- 2.3.3
|
- 2.3.3
|
||||||
- ruby-head
|
- ruby-head
|
||||||
- jruby-9.0.4.0
|
- jruby-9.1.5.0 # is precompiled per http://rubies.travis-ci.org/
|
||||||
- jruby-head
|
- jruby-head
|
||||||
|
|
||||||
jdk:
|
jdk:
|
||||||
- oraclejdk8
|
- oraclejdk8
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- gem update --system
|
||||||
|
- rvm @global do gem uninstall bundler -a -x
|
||||||
|
- rvm @global do gem install bundler -v 1.13.7
|
||||||
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
|
install: bundle install --path=vendor/bundle --retry=3 --jobs=3
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
@ -35,13 +39,13 @@ matrix:
|
|||||||
exclude:
|
exclude:
|
||||||
- rvm: 2.1
|
- rvm: 2.1
|
||||||
env: RAILS_VERSION=master
|
env: RAILS_VERSION=master
|
||||||
- rvm: jruby-9.0.4.0
|
- rvm: jruby-9.1.5.0
|
||||||
env: RAILS_VERSION=master
|
env: RAILS_VERSION=master
|
||||||
- rvm: jruby-head
|
- rvm: jruby-head
|
||||||
env: RAILS_VERSION=master
|
env: RAILS_VERSION=master
|
||||||
- rvm: 2.1
|
- rvm: 2.1
|
||||||
env: RAILS_VERSION=5.0
|
env: RAILS_VERSION=5.0
|
||||||
- rvm: jruby-9.0.4.0
|
- rvm: jruby-9.1.5.0
|
||||||
env: RAILS_VERSION=5.0
|
env: RAILS_VERSION=5.0
|
||||||
- rvm: jruby-head
|
- rvm: jruby-head
|
||||||
env: RAILS_VERSION=5.0
|
env: RAILS_VERSION=5.0
|
||||||
|
|||||||
@ -17,6 +17,7 @@ Misc:
|
|||||||
- [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) Make test attributes explicit. Tests have Model#associations. (@bf4)
|
- [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) Make test attributes explicit. Tests have Model#associations. (@bf4)
|
||||||
- [#1981](https://github.com/rails-api/active_model_serializers/pull/1981) Fix relationship link documentation. (@groyoh)
|
- [#1981](https://github.com/rails-api/active_model_serializers/pull/1981) Fix relationship link documentation. (@groyoh)
|
||||||
- [#2035](https://github.com/rails-api/active_model_serializers/pull/2035) Document how to disable the logger. (@MSathieu)
|
- [#2035](https://github.com/rails-api/active_model_serializers/pull/2035) Document how to disable the logger. (@MSathieu)
|
||||||
|
- [#2039](https://github.com/rails-api/active_model_serializers/pull/2039) Documentation fixes. (@biow0lf)
|
||||||
|
|
||||||
### [v0.10.4 (2017-01-06)](https://github.com/rails-api/active_model_serializers/compare/v0.10.3...v0.10.4)
|
### [v0.10.4 (2017-01-06)](https://github.com/rails-api/active_model_serializers/compare/v0.10.3...v0.10.4)
|
||||||
|
|
||||||
|
|||||||
12
appveyor.yml
12
appveyor.yml
@ -1,4 +1,4 @@
|
|||||||
version: '{build}'
|
version: 1.0.{build}-{branch}
|
||||||
|
|
||||||
skip_tags: true
|
skip_tags: true
|
||||||
|
|
||||||
@ -7,17 +7,23 @@ environment:
|
|||||||
matrix:
|
matrix:
|
||||||
- ruby_version: "Ruby21"
|
- ruby_version: "Ruby21"
|
||||||
- ruby_version: "Ruby21-x64"
|
- ruby_version: "Ruby21-x64"
|
||||||
- ruby_version: "jruby-9.0.0.0"
|
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
- vendor/bundle
|
- vendor/bundle
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- SET PATH=C:\%ruby_version%\bin;%PATH%
|
- SET PATH=C:\%ruby_version%\bin;%PATH%
|
||||||
- gem install bundler
|
- gem update --system
|
||||||
|
- gem uninstall bundler -a -x
|
||||||
|
- gem install bundler -v 1.13.7
|
||||||
- bundle env
|
- bundle env
|
||||||
- bundle install --path=vendor/bundle --retry=3 --jobs=3
|
- bundle install --path=vendor/bundle --retry=3 --jobs=3
|
||||||
|
|
||||||
|
before_test:
|
||||||
|
- ruby -v
|
||||||
|
- gem -v
|
||||||
|
- bundle -v
|
||||||
|
|
||||||
test_script:
|
test_script:
|
||||||
- bundle exec rake ci
|
- bundle exec rake ci
|
||||||
|
|
||||||
|
|||||||
@ -77,13 +77,13 @@ If you are using `JSON` adapter, pagination links will not be included automatic
|
|||||||
Add this method to your base API controller.
|
Add this method to your base API controller.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
def pagination_dict(object)
|
def pagination_dict(collection)
|
||||||
{
|
{
|
||||||
current_page: object.current_page,
|
current_page: collection.current_page,
|
||||||
next_page: object.next_page,
|
next_page: collection.next_page,
|
||||||
prev_page: object.prev_page, # use object.previous_page when using will_paginate
|
prev_page: collection.prev_page, # use collection.previous_page when using will_paginate
|
||||||
total_pages: object.total_pages,
|
total_pages: collection.total_pages,
|
||||||
total_count: object.total_count
|
total_count: collection.total_count
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
@ -117,18 +117,18 @@ ex.
|
|||||||
You can also achieve the same result if you have a helper method that adds the pagination info in the meta tag. For instance, in your action specify a custom serializer.
|
You can also achieve the same result if you have a helper method that adds the pagination info in the meta tag. For instance, in your action specify a custom serializer.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
render json: @posts, each_serializer: PostPreviewSerializer, meta: meta_attributes(@post)
|
render json: @posts, each_serializer: PostPreviewSerializer, meta: meta_attributes(@posts)
|
||||||
```
|
```
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
#expects pagination!
|
#expects pagination!
|
||||||
def meta_attributes(resource, extra_meta = {})
|
def meta_attributes(collection, extra_meta = {})
|
||||||
{
|
{
|
||||||
current_page: resource.current_page,
|
current_page: collection.current_page,
|
||||||
next_page: resource.next_page,
|
next_page: collection.next_page,
|
||||||
prev_page: resource.prev_page, # use resource.previous_page when using will_paginate
|
prev_page: collection.prev_page, # use collection.previous_page when using will_paginate
|
||||||
total_pages: resource.total_pages,
|
total_pages: collection.total_pages,
|
||||||
total_count: resource.total_count
|
total_count: collection.total_count
|
||||||
}.merge(extra_meta)
|
}.merge(extra_meta)
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user