-
Notifications
You must be signed in to change notification settings - Fork 333
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
Configurations for json output #4
Comments
Right now you can do:
and it will add a root node "people" BUT there will still be a "person" label inside for every person i.e:
That is how I prefer it, but I can see the need for the other way:
Currently that way isn't possible. |
The defaults you have in there are good. If someone want's to override them, I really think this should be explicit in the rabl template. There shouldn't be any implicit setting that changes the defaults project wide. I'd suggest the syntax
Thanks! |
You are right after I thought about it a bit more. That syntax is probably a good way to do it. Will leave that for another day since I never need it in my apis. Thanks for your help with identifying these issues. |
cool. it's not a blocking issue for me so no rush. if i have any spare time i'll maybe use this as an excuse to try to understand the rabl codebase and hopefully contribute a patch |
That'd be appreciated, thanks |
I wish this issue will be closed as soon as possible. Thanks for this awesome gem, you are my hero now :) |
If somebody is looking for a quick dirty hack for this — I can suggest replace |
Glad you like the gem so far, this is low priority for me since I don't need it for any of my projects. But I am happy to pull in any patches that address this. |
Bit of an update for this with a new option "child_root" which can be passed into the builder that affects this behavior. Essentially, we just need to close the loop by deciding on a syntax and exposing this functionality per-template. "child_root" here: 7065793 |
Merging this ticket here: He had:
But wanted:
Had have builder template index.json.rabl for People#index controller with
and the collection of objects => @people |
Ok this has been completed and I have added the concept of rabl global settings configuration. @railsjedi @ognevsky @joel Check the README for more details on configuration. Can you guys all try this from the repo directly. If it works without issue, I will push a new gem version. Commits here and here Configuration with: # config/initializers/rabl_init.rb
Rabl.configure do |config|
config.include_json_root = false
end |
Awesome! Yahoo! |
Let me know if it works as expected. Thanks. |
this is very good but this does not cover all cases, we can not define the behavior for each rendering, the proposal of railsjedi seems to necessary. |
At least a step in the right direction, and opens up the possibility for future configuration options at a global level. |
exactly! and it's great! |
I tried to work with ActiveResource:: Base and json format. To activate self.format =: json you must remove the root! So thank you for adding this feature! If you don't use an builder just add self.include_root_in_json=false in ActiveRecord:: Base Model called. |
Don't choke on symbol attribute values.
On a project and template basis, there needs to be configuration. Namely,
users : { ... }
And probably others I can't think of right now.
The text was updated successfully, but these errors were encountered: