<commit_before>module AutocompleteSelectHelper
  # Return a html script tag which includes the required javascript
  # files for autocomplete_select to operate.
  def autocomplete_select_includes
    javascript_include_tag "autocomplete_select/autocomplete_select.js"
  end
  
  # Create a autocompleting select field for the provided object and
  # method.  An example:
  #
  #   <% form_for :client do |f| %>
  #     <%= f.autocomplete_select :company_id %>
  #   <% end %>
  #
  # The above example will use the +company+ resource index with the
  # parameter +search+ to try and complete the entered company.
  #
  # A block may be given to add extra HTML snippets after the input
  # field;
  #
  #   <% f.autocomplete_select :company_id do %>
  #     Enter company name
  #   <% end %>
  #
  # The field will fire a change event when a selection is made.  Pass
  # a +onchange+ in +options+ to set it up;
  #
  #  <%= f.autocomplete_select :company_id, :onchange => 'App.updateCompany(this.value)' %>
  #
  # When the named association can not derived from the given
  # +method+, the +association+ option can be passed.
  #
  # The resource url is constructed from the association name with
  # +polymorphic_path+.  Extra options can be passed with the
  # +url_options+ option.
  # 
  # The visible value is normally obtained by calling +to_s+ on the
  # currently selected instance.  Use the +val_fn+ option to pass an
  # alternative Proc object.  Don't forget to produce simular output
  # in your autocomplete response in the associated controller/view.
  # 
  # The remaining options are passed to the hidden field which will
  # hold the id of the selected object.
  def autocomplete_select(object, method, options = {}, &block)
    attribute = method.to_s.gsub(/_id$/, '')
    association = options.delete(:association) || attribute
    errors = options[:object].errors
    disabled = options.delete(:disabled)
    val_fn = options.delete(:val_fn) || lambda{|val| h(val.to_s)}
    resource_url = polymorphic_path(association.to_s.pluralize,
                                    {:format => :autocomplete}.
                                    merge(options.delete(:url_options) || {}))
    input_options,<commit_msg>allow alternative resource_url<commit_after>module AutocompleteSelectHelper
  # Return a html script tag which includes the required javascript
  # files for autocomplete_select to operate.
  def autocomplete_select_includes
    javascript_include_tag "autocomplete_select/autocomplete_select.js"
  end
  
  # Create a autocompleting select field for the provided object and
  # method.  An example:
  #
  #   <% form_for :client do |f| %>
  #     <%= f.autocomplete_select :company_id %>
  #   <% end %>
  #
  # The above example will use the +company+ resource index with the
  # parameter +search+ to try and complete the entered company.
  #
  # A block may be given to add extra HTML snippets after the input
  # field;
  #
  #   <% f.autocomplete_select :company_id do %>
  #     Enter company name
  #   <% end %>
  #
  # The field will fire a change event when a selection is made.  Pass
  # a +onchange+ in +options+ to set it up;
  #
  #  <%= f.autocomplete_select :company_id, :onchange => 'App.updateCompany(this.value)' %>
  #
  # When the named association can not derived from the given
  # +method+, the +association+ option can be passed.
  #
  # The resource url is constructed from the association name with
  # +polymorphic_path+.  Extra options can be passed with the
  # +url_options+ option.  The entire url can be overridden by passing
  # a +resource_url+ option.
  # 
  # The visible value is normally obtained by calling +to_s+ on the
  # currently selected instance.  Use the +val_fn+ option to pass an
  # alternative Proc object.  Don't forget to produce simular output
  # in your autocomplete response in the associated controller/view.
  # 
  # The remaining options are passed to the hidden field which will
  # hold the id of the selected object.
  def autocomplete_select(object, method, options = {}, &block)
    attribute = method.to_s.gsub(/_id$/, '')
    association = options.delete(:association) || attribute
    errors = options[:object].errors
    disabled = options.delete(:disabled)
    val_fn = options.delete(:val_fn) || lambda{|val| h(val.to_s)}
    resource_url = options.delete(:resource_url) ||
      polymorphic_path(association.to_s.pluralize,
                       {:format => :autocomplete}.
                       merge(options.delete(:url_options) || {}))
    input_options,
{'fraction_non_alphanumeric': 0.09074967119684349, 'fraction_numerical': 0.0, 'mean_word_length': 3.264485981308411, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3290151', 'n_tokens_mistral': 1376, 'n_tokens_neox': 1296, 'n_words': 463}