On Mar 18, 9:40 pm, Dudebot <[email protected]> wrote: > Anybody have any idea why this is throwing an error: > > @monkey = params[ :lab ][ :existing_lab_data_attributes ] > raise @monkey.to_yaml > > --- !map:HashWithIndifferentAccess > "133": !map:HashWithIndifferentAccess > unit_id: "2" > lab_desc_id: "2" > value: "500" > "145": !map:HashWithIndifferentAccess > unit_id: "4" > lab_desc_id: "3" > value: "" > ... > > But when I try > > @monkey.delete_if{ |x| x[ :value ].blank? } >
Because @monkey is a hash what gets yielded to you is an array, the first element is the key (ie '133' or '145') and the second is the value, whereas your code seems to assume that x is a hash. Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

