I would like to refactor this block, it looks clunky:# refactor mereceive_payment_on = falseconfig[:sections].each do |section|  if section[:applicants]    section[:applicants][:sections].each do |app_sec|      if app_sec[:employment] && app_sec[:employment][:receive_payment_on]        receive_payment_on = true      end    end  endend
Setting receive_payment_on flag for employment applicants
ruby;ruby on rails
Put your code into a method. So you get rid of the temporary variable, its cleaner and you can leave your method with a return as soon as you find the first true. (A break to leave the loop will have the same effect.)In addition to that I'm a big friend of guard conditions. Invert if section[:applicants] ... end to if !section[:applicants] next, so you have one nesting level less. ...config[:sections].each do |section|   if !section[:applicants] next   section[:applicants][:sections].each do |app_sec|       if app_sec[:employment] && app_sec[:employment][:receive_payment_on]           return true       end   endendreturn false