<commit_before><div id="dropzone_<%= method %>_<%= cycle(*(1..999).to_a, name: method) %>" class="dropzone">
  <span class="notice"><%=t 'dropzone.drag_or_click' %></span>
  <%= hidden_field_tag "#{ object.class.model_name.singular }[#{ method }_attributes][-1]", "" %>
  <% object.send(method).each_with_index do |dropzone_object, index| %>
    <%= hidden_field_tag "#{ object.class.model_name.singular }[#{ method }_attributes][#{ dropzone_object.id }][#{ object.class.send("dropzone_#{ method }_field", :title) }]", dropzone_object.send(object.class.send("dropzone_#{ method }_field", :title)) %>
  <% end %>
</div>

<% unless options[:hint].blank? %>
  <p class="inline-hints dropzone-hint"><%= options[:hint] %></p>
<% end %>

<script>
  (function() {
    Dropzone.autoDiscover = false;

    var mockFiles = <%= render_mock_dropzone_files(object.send(method)) %>;
    var dropzone_id = "#dropzone_<%= method %>_<%= current_cycle(method) %>"; 
    var dropzone_options = { 
      url: '<%= raw upload_dropzone_path(dropzonable_id: (object.new_record? ? nil : object.id), dropzonable_class: object.class, dropzone_class: object.class.send("dropzone_#{ method }_class")) %>',
      addRemoveLinks: true,
      dictCancelUpload: '<%=t "dropzone.cancel" %>',
      dictRemoveFile: '<%=t "dropzone.remove" %>',
      maxFiles: <%= defined?(max_files) ? '1' : 'null' %>,
      sending: function(file, xhr, formData) {
        xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').prop('content'));
      },
      success: function(file, data) {
        $(dropzone_id).append('<input type="hidden" name="<%= object.class.model_name.singular %>[<%= method %>_attributes][' + data.id + '][<%= object.class.send("dropzone_#{ method }_field", :title) %>]" value="' + data.title + '" />');
        $(file.previewElement).attr('data-id', data.id);
        $(file.previewElement).attr('data-url', data.url);
        $(file.previewElement).find('.dz-filename span').text(data.title);
        return file.previewElement.classList.add("dz-success");
      },
      removedfile: function(file) {
        $(dropzone_id + ' input[name="<%= object.class.model_name.singular %>[<%= method %>_attributes][' + file.id + '][<%= object.class.send("dropzone_#{ method }_field", :title) %>]"]').remove();
        $(dropzone_id + ' input[name="<%= object.class.model_name.singular %>[<%= method %>_attributes][' + file.id + '][<%= object.class.send("dropzone_#{ method }_field", :position) %>]"]').remove();
        $(file.previewElement).remove();
        $(dropzone_id).sortable('refresh');
      }
    };
    
    if (window.<%= method %>_dropzone_preview_template || window.dropzone_preview_template) {
      dropzone_options['previewTemplate'] = window.<%= method %>_dropzone_preview_template || window.dropzone_preview_template;
    }
    
    var dropzone = new Dropzone(dropzone_id, dropzone_options);
<commit_msg>correction to work with polymorphic<commit_after><div id="dropzone_<%= method %>_<%= cycle(*(1..999).to_a, name: method) %>" class="dropzone">
  <span class="notice"><%=t 'dropzone.drag_or_click' %></span>
  <% object.send(method).each_with_index do |dropzone_object, index| %>
    <%= hidden_field_tag "#{ object.class.model_name.singular }[#{ method }_attributes][#{ dropzone_object.id }][#{ object.class.send("dropzone_#{ method }_field", :title) }]", dropzone_object.send(object.class.send("dropzone_#{ method }_field", :title)) %>
  <% end %>
</div>

<% unless options[:hint].blank? %>
  <p class="inline-hints dropzone-hint"><%= options[:hint] %></p>
<% end %>

<script>
  (function() {
    Dropzone.autoDiscover = false;

    var mockFiles = [<%= render_mock_dropzone_files(object.send(method)) %>];
    var dropzone_id = "#dropzone_<%= method %>_<%= current_cycle(method) %>";
    var dropzone = new Dropzone(dropzone_id, {
      url: '<%= raw upload_dropzone_path(dropzonable_class: object.class, dropzone_class: object.class.send("dropzone_#{ method }_class")) + '&' + "dropzonable_id=#{object.id}" %>' ,
      addRemoveLinks: true,
      dictCancelUpload: '<%=t "dropzone.cancel" %>',
      dictRemoveFile: '<%=t "dropzone.remove" %>',
      maxFiles: <%= defined?(max_files) ? '1' : 'null' %>,
      sending: function(file, xhr, formData) {
        xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').prop('content'));
      },
      success: function(file, data) {
        $(dropzone_id).append('<input type="hidden" name="<%= object.class.model_name.singular %>[<%= method %>_attributes][' + data.id + '][<%= object.class.send("dropzone_#{ method }_field", :title) %>]" value="' + data.title + '" />');
        $(file.previewElement).attr('data-id', data.id);
        $(file.previewElement).attr('data-url', data.url);
        $(file.previewElement).find('.dz-filename span').text(data.title);
        return file.previewElement.classList.add("dz-success");
      },
      removedfile: function(file) {
        $(dropzone_id + ' input[name="<%= object.class.model_name.singular %>[<%= method %>_attributes][' + file.id + '][<%= object.class.send("dropzone_#{ method }_field", :title) %>]"]').remove();
        $(dropzone_id + ' input[name="<%= object.class.model_name.singular %>[<%= method %>_attributes][' + file.id + '][<%= object.class.send("dropzone_#{ method }_field", :position) %>]"]').remove();
        $(file.previewElement).remove();
        $(dropzone_id).sortable('refresh');
      }
    });

{'fraction_non_alphanumeric': 0.21664829106945976, 'fraction_numerical': 0.002021315692760015, 'mean_word_length': 4.492431886982845, 'pattern_counts': {'":': 0, '<': 72, '<?xml version=': 0, '>': 72, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4998349', 'n_tokens_mistral': 1877, 'n_tokens_neox': 1781, 'n_words': 286}