<commit_before>module ActiveScaffold::Actions
  module Core
    def self.included(base)
      base.class_eval do
        after_filter :clear_flashes
      end
    end
    def render_field
      @record = active_scaffold_config.model.new
      column = active_scaffold_config.columns[params[:column]]
      value = if column.association
        params[:value].blank? ? nil : column.association.klass.find(params[:value])
      else
        params[:value]
      end
      @record.send "#{column.name}=", value
      @update_columns = Array(column.options[:update_column]).collect {|column_name| active_scaffold_config.columns[column_name]}
    end

    protected

    def authorized_for?(*args)
      active_scaffold_config.model.authorized_for?(*args)
    end

    def clear_flashes
      if request.xhr?
        flash.keys.each do |flash_key|
          flash[flash_key] = nil
        end
      end
    end

    def default_formats
      [:html, :js, :json, :xml, :yaml]
    end
    # Returns true if the client accepts one of the MIME types passed to it
    # ex: accepts? :html, :xml
    def accepts?(*types)
      for priority in request.accepts.compact
        if priority == Mime::ALL
          # Because IE always sends */* in the accepts header and we assume
          # that if you really wanted XML or something else you would say so
          # explicitly, we will assume */* to only ask for :html
          return types.include?(:html)
        elsif types.include?(priority.to_sym)
          return true
        end
      end
      false<commit_msg>fixed nil exception in case of an unknown column in params added hook after_render_field<commit_after>module ActiveScaffold::Actions
  module Core
    def self.included(base)
      base.class_eval do
        after_filter :clear_flashes
      end
    end
    def render_field
      @record = active_scaffold_config.model.new
      @update_columns = []
      column = active_scaffold_config.columns[params[:column]]
      unless column.nil?
        value = if column.association
          params[:value].blank? ? nil : column.association.klass.find(params[:value])
        else
          params[:value]
        end
        @record.send "#{column.name}=", value
        @update_columns << Array(column.options[:update_column]).collect {|column_name| active_scaffold_config.columns[column_name]}
        @update_columns.flatten!
        after_render_field(@record, column)
      end
    end

    protected
    
    # override this method if you want to do something after render_field
    def after_render_field(record, column); end

    def authorized_for?(*args)
      active_scaffold_config.model.authorized_for?(*args)
    end

    def clear_flashes
      if request.xhr?
        flash.keys.each do |flash_key|
          flash[flash_key] = nil
        end
      end
    end

    def default_formats
      [:html, :js, :json, :xml, :yaml]
    end
    # Returns true if the client accepts one of the MIME types passed to it
    # ex: accepts? :html, :xml
    def accepts?(*types)
      for priority in request.accepts.compact
        if priority == Mime::ALL
          # Because IE always sends */* in the accepts header and we assume
          # that if you really wanted XML or something else you would say so
          # explicitly, we will assume */* to only ask for :html
          return types.include?(:html)
        elsif types.include?(priority.to_sym)
          return true
        end
      end
      false
{'fraction_non_alphanumeric': 0.08318940702360392, 'fraction_numerical': 0.0, 'mean_word_length': 2.4542743538767398, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4422134', 'n_tokens_mistral': 992, 'n_tokens_neox': 983, 'n_words': 292}