Conversation
|
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @rwz (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
lib/jbuilder.rb
Outdated
There was a problem hiding this comment.
Yes it should. Thanks for pointing that out.
|
@abhiQmar Doesn't jbuilder already check for blank values? |
|
@nateberkopec No it doesn't, it makes sense if someone wants to blank arrays, nils and strings(for consistency) in their json output. But if you do not want any blank arrays or empty strings (my use case), you would have to put a check on each and every key-value pair. There is a method(ignore_nil!) to ignore the keys with nil values. I am just trying to extend this functionality so that we can check for anything on our keys cleanly, by sending a block [which if returns true will ignore the key-value pair]. |
8be11c8 to
23e05c0
Compare
Use case:
I had to write checks on each line to ignore keys with empty array or empty string values.
the above code now becomes: