Skip to content

Commit ab824e2

Browse files
authored
Merge pull request #2039 from biow0lf/documentation-fixes
Documentation fixes
2 parents 9ccdb15 + 775ad66 commit ab824e2

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Misc:
1616

1717
- [#2021](https://github.com/rails-api/active_model_serializers/pull/2021) Make test attributes explicit. Tests have Model#associations. (@bf4)
1818
- [#1981](https://github.com/rails-api/active_model_serializers/pull/1981) Fix relationship link documentation. (@groyoh)
19+
- [#2039](https://github.com/rails-api/active_model_serializers/pull/2039) Documentation fixes. (@biow0lf)
1920

2021
### [v0.10.4 (2017-01-06)](https://github.com/rails-api/active_model_serializers/compare/v0.10.3...v0.10.4)
2122

docs/howto/add_pagination_links.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,13 @@ If you are using `JSON` adapter, pagination links will not be included automatic
7777
Add this method to your base API controller.
7878

7979
```ruby
80-
def pagination_dict(object)
80+
def pagination_dict(collection)
8181
{
82-
current_page: object.current_page,
83-
next_page: object.next_page,
84-
prev_page: object.prev_page, # use object.previous_page when using will_paginate
85-
total_pages: object.total_pages,
86-
total_count: object.total_count
82+
current_page: collection.current_page,
83+
next_page: collection.next_page,
84+
prev_page: collection.prev_page, # use collection.previous_page when using will_paginate
85+
total_pages: collection.total_pages,
86+
total_count: collection.total_count
8787
}
8888
end
8989
```
@@ -117,18 +117,18 @@ ex.
117117
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.
118118

119119
```ruby
120-
render json: @posts, each_serializer: PostPreviewSerializer, meta: meta_attributes(@post)
120+
render json: @posts, each_serializer: PostPreviewSerializer, meta: meta_attributes(@posts)
121121
```
122122

123123
```ruby
124124
#expects pagination!
125-
def meta_attributes(resource, extra_meta = {})
125+
def meta_attributes(collection, extra_meta = {})
126126
{
127-
current_page: resource.current_page,
128-
next_page: resource.next_page,
129-
prev_page: resource.prev_page, # use resource.previous_page when using will_paginate
130-
total_pages: resource.total_pages,
131-
total_count: resource.total_count
127+
current_page: collection.current_page,
128+
next_page: collection.next_page,
129+
prev_page: collection.prev_page, # use collection.previous_page when using will_paginate
130+
total_pages: collection.total_pages,
131+
total_count: collection.total_count
132132
}.merge(extra_meta)
133133
end
134134
```

0 commit comments

Comments
 (0)