<% recent_deal_patterns = current_user.deal_patterns.recent.limit(10).all %>
<% unless recent_deal_patterns.empty? %>
  <!-- recent deal patterns -->
  <div id="recent_deal_patterns" class="side_box">
    <h4>最近の記入パターン</h4>
    <%= render :partial => 'shared/deal_patterns/deal_pattern', :collection => recent_deal_patterns %>
  </div>
  <%= javascript_tag do %>
    jQuery(document).ready(function($){
      $('a.new_deal_with_pattern_link').click(function() {
        $('#notice').hide()
        $('#deal_forms').load(this.href, null, function() {
          $('#deal_pattern_frame').load('<%= recent_deal_patterns_path %>')
        })
        return false
      })
    })
  <% end %>
<% end %>

<% recent_deal_patterns = current_user.deal_patterns.includes(:readonly_entries).recent.limit(10).all %>
<% unless recent_deal_patterns.empty? %>
  <!-- recent deal patterns -->
  <div id="recent_deal_patterns" class="side_box">
    <h4>最近の記入パターン</h4>
    <%= render :partial => 'shared/deal_patterns/deal_pattern', :collection => recent_deal_patterns %>
  </div>
  <%= javascript_tag do %>
    jQuery(document).ready(function($){
      $('a.new_deal_with_pattern_link').click(function() {
        $('#notice').hide()
        $('#deal_forms').load(this.href, null, function() {
          $('#deal_pattern_frame').load('<%= recent_deal_patterns_path %>')
        })
        return false
      })
    })
  <% end %>
<% end %>

Refactor to include entries in deal patern search.
Refactor to include entries in deal patern search.
