title: Update information in a Hash associated to an ActiveRecord rails 5
body: <p>I have an two hashes where one is called <code>current_savings</code> and one called <code>mambu_repayments</code></p>
  
  <pre><code>current_savings.select {|s| s[:status] == 'repaid' }
  </code></pre>
  
  <p>In <strong><code>rails c</code></strong> the above will output any savings where status is repaid. </p>
  
  <pre><code>mambu_repayments.last
  </code></pre>
  
  <p>In <strong>rails c</strong> the above line will output the repayment. This hash has key value element <code>"state"=&gt;"PAID"</code></p>
  
  <p>I want change that state value to COMPLETE for every last repayment where current_savings status is marked repaid. </p>
  
  <p>In my relevant controller I have tried the following: </p>
  
  <pre><code> # check saving is not nil and status is :repaid.
      # Retrieve last repayment from @repayments and check if it has status PAID
  
      if current_savings != nil? &amp;&amp; current_savings.status == 'repaid'
        mambu_repayments = current_savings.get_repayments_with_parents.select{|s| s["state"] == 'PAID'}
        mambu_repayments.last = 'COMPLETE'
      end
  </code></pre>