I have a Photo class that has a "name" attribute and a "tags" attribute. My goal is to implemented an update function in Rails that replaces the photo's tags with whatever was inputted. For example, if I try to PUT a JSON object that has "tags" set to [], I want any tags to be cleared from the photo.
However, when I submit an empty array through HTTParty as one of the body parameters, I believe that HTTParty is translating [] into nil. Therefore the photos#update endpoint on my Rails backend receives nothing for the parameter "tags". I am looking for a way for HTTParty to not convert [] into nil because I lose the ability to remove tags from the photo.
This is a bug/feature in Rails 4, you can read more about the drama at: https://github.com/rails/rails/issues/13420
Your options include:
deep_munge
everywhere, and deal with the consequences of that:>
# config/application.rb
config.action_dispatch.perform_deep_munge = false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With