-
-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
_canLoadMore doesn't fetch totalPages #99
Comments
The response needs to look like this: {
items: [
{id: 1, name: 'Test'},
{id: 2, name: 'Test 2'}
],
meta: {
total_pages: 3
}
} |
Thank's for reply, works great now :) |
@szsoppa did you find a good solution for including the pages data in the JSON response under meta? I'm using headers now too, and can't find much on the backend with kaminari or grape on how to structure that properly. |
I used https://github.com/monterail/grape-kaminari gem to return all of the data required by ember-infinity. You can see in documentation that it's pretty simple to use. |
Thanks @szsoppa - I'm still not seeing where in grape-kaminari to tell it to include the total_pages in meta as part of the json response.. Is it conflicting with active_model_serializers perhaps? |
It may have a problem with |
Found this https://github.com/ruby-grape/grape-active_model_serializers#custom-metadata to modify the Rails side, or this http://codeandtechno.com/posts/metadata-via-response-headers-in-emberjs/ to modify the Ember side. For anyone who might need it.. |
Be aware that the default is "total_pages" with an underscore and you might be returning dasherized attribute names. Also, the latest ASM includes links metadata by default, more here on that. I had this issue and you can read more about it here. My controller renders like this:
|
I have a problem witth totalPages parameter. I use kaminari gem together with grape to serve paginated data from server. Payload header looks like this:
As you can see total-pages is present here but when I stopped
_canLoadMore
in my route to see what's going on there I got nothing when trying to to thisthis.get('_totalPages')
It seems like it doesn't fetch totalPages. When I return true in_canLoadMore
everything works fine.The text was updated successfully, but these errors were encountered: