<% @descriptions.each_with_index do |description, i| %>  <% description.tale2.each do |tax_ref| %>                <% if condition %>                    <% if condition %>        <% if condition %>                            <%= $text_first_describe%> <%= $paren_author_yr %>             <% ref_sp_uniq.each_with_index do |ref, i| %>               <% if ref == tax_ref.ref_wo_brace%>                  <% execution %>                                     <% elsif i == (ref_sp_uniq.size - 1)%>                  <%# @ref_desc = #{@ref_desc_numb}. #{tax_ref.ref_wo_brace} %>               <% end %>             <% end %>          <% if condition %>                  <% execution %>                                <% elsif condition %>            <% execution %>          <% elsif taxon_name.emend_author_year %>                                 <%= print %>          <% else %>                                 <%= print %>                              <% end %>        <% end %>      <% else %>        <% if condition %>          <%= print %>          <% ref_sp_uniq.each_with_index do |ref, i| %>             <% if condition %>                <% execution %>                                   <% elsif condition %>                  <% execution %>                                   <% end %>          <% end %>          <% if condition %>            <% execution %>                                <% elsif condition %>            <% execution %>                                <% elsif condition %>            <% execution %>                                <% else %>            <% execution %>                                <% end %>        <% end %>      <% end %>    <% end %>  <% end %>        <% end %>
How to reduce number of hierarchical 'if statements'
ruby;ruby on rails
In general, you can try inverting the condition on your outermost if block, and work your way in.  This will often result in less nesting, eg:if condition1  if condition2    #ifblock  else    #elseblock2  endelse  #elseblockendInside a loop, as you have your code, it would become this strcture, which is less nested:if !condition  #elseblock  nextendif !condition2  #elseblock2  nextend#ifblock