How do I find and replace 'nil' values of Ruby hash with “None” or 0?
问题 I'm trying to drill down to each value in an iteration of an array nested hash and replace all nil values with something like 'None' or 0. Please see my code that is clearly not working. I need to fix this before I pass it to my Views in Rails for iteration and rendering: My controller: def show results = Record.get_record(params[:trans_uuid]) if !results.empty? record = results.map { |res| res.attributes.symbolize_keys } @record = Record.replace_nil(record) # this calls method in Model else