title: Ruby - Delete value from Hash
body: <p>I'm trying to delete an attribute and its value from a hash. Its seems simple based on answers I see on here but it doesn't appear to work for me. Curious if anyone has any thoughts as to why? Also... this is NOT a duplicate of the question that was linked. I have tried except and slice... neither of those work as well. I'm guessing my dataset it different.</p>
  
  <p>Here is an example hash I have:</p>
  
  <pre><code> {:data=&gt;[{:id=&gt;1, :make=&gt;"Ford", :model=&gt;"Excursion", :year=&gt;2018, :color=&gt;"silver", :vin=&gt;"123456789F22"},{=&gt;[{:id=&gt;2, :make=&gt;"Mazda", :model=&gt;"RX7", :year=&gt;1980, :color=&gt;"blue", :vin=&gt;"123456789F22"},{=&gt;[{:id=&gt;3, :make=&gt;"Chevy", :model=&gt;"Dorado", :year=&gt;2018, :color=&gt;"white", :vin=&gt;"123456789F22"}]}
  </code></pre>
  
  <p>I have tried the following:</p>
  
  <pre><code> hashval.delete("color")
   hashval.except!("color")
   hashval.each {|h| h.delete("color")}  
  </code></pre>
  
  <p>I also tried :color in case the string format was wrong</p>
  
  <pre><code> hashval.delete(:color)
   hashval.except!(:color)
   hashval.each {|h| h.delete(:color)}  
  </code></pre>
  
  <p>but when I try to display the resulting hash</p>
  
  <pre><code> logger.info "hash result: #{hashval}"
  </code></pre>
  
  <p>I still see the original hash with the color still in there. Any thoughts on what I am doing wrong?</p>
  
  <p>Ok... more info!  If I do this:</p>
  
  <pre><code> hashval.delete(:data)
  </code></pre>
  
  <p>It does delete :data (and everything else after that). So it has something to do with the attributes in that hash array? </p>
  
  <p>As it turns out, the answer is:</p>
  
  <pre><code> hashval = { data: vehicles.map { |v| v.table_data.except(:color) } }
  </code></pre>
  
  <p>I guess this issue was marked closed as a duplicate (even though it wasn't) so I cant add the solution. </p>