i was wondering if there is any way to just skip attributes having nil values when to_json on ActiveRecord. The default behavior is to include a nil value:
Is there
For any hash array, here is what I usually do considering that any value besides false and nil will be considered true:
filtered_array = array.select{|k,v| v}
Or the bang alternative:
array.select!{|k,v| v}
This will NOT work, though, if the values could reliably be the boolean value false.