I have some code that is chugging through a set of Rails Active Record models, and setting an attribute based on a related value from a 2D Array. 

I am essentially setting a US State abbreviation code in a table of US States which was previously only storing the full names. A library of state names is being used to derive the abbreviations, and it contains a 2D Array with each sub-array having a full name, and an abbreviation (i.e., `[['New York', 'NY']['Pennsylvania', 'PA'][etc]]`). I compare the state name from each record in the database to each full text name in this Array, then grab the corresponding sibling Array cell when there is a match.

This code works fine, and produces the correct results, but its frumpy looking and not easily understood without reading many lines:

```
# For the following code, StatesWithNames is an Active Record model, which is
#  having a new column :code added to its table.
# Sates::USA represents a 2D Array as: [['StateName', 'NY']], and is used to 
#  populate the codes for StatesWithNames. 
# A comparison is made between StatesWithNames.name and the text name found in
#  States::USA, and if there is a match, the abbreviation from States::USA is
#  used
if StatesWithNames.any? 
  StatesWithNames.all.each do |named_state|
    if named_state.code.blank?
      States::USA.each do |s|
        if s[0] == named_state.name
          named_state.update_column(:code, s[1])
          break
        end
      end
    end
  end
end

```

What is the most Ruby style way of expressing assignments with logic like this? I experimented with a few different procs / blocks, but arrived at even cludgier expressions, or incorrect results. Is there a more simple way to express this in fewer lines and/or `if-end` conditionals?