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
Generating JSOS suitable for use by jQuery DataTables #405
Comments
try adding:
to the top of the template |
Adding I get this from my Rabl
but this is the JSON I need to get (and that I do get from my Ruby method.)
As you can see, the Rabl version includes all sorts of extra info from the Recipe object, and the 'aaData' array is an array of named 'recipe' objects, not an array of anonymous objects. |
Ahh i see it now:
needs to be
in node :aaData do. .each returns the entire recipe object. |
Kick ass, that worked! Thanks. |
FYI the presence of |
Yeah exactly, use map along with node. |
I am making extensive use of jQuery Datatables and they require JSON feeds in a specific format which Rabl can't provide. The issue is I need to return un-named arrays which I can't work out how to get Rable to do.
I have resorted to coding up a helper in my Sinatra app to generate the appropriate JSON but would prefer to have this logic in a Rabl file if possible. Maybe I'm just missing something.
My working method is:
How would I get the same result in Rabl?
I tried this:
but that wraps the array of recipes in a 'recipes' object and also seems to include all the other recipe attributes (not shown), even though I don't require them.
I'd love to move all my JSON rendering into Rabl but this example has me stumped.
The text was updated successfully, but these errors were encountered: