<commit_before>module ActiveScaffold::Actions
  module Show
    def self.included(base)
      base.before_filter :show_authorized_filter, :only => :show
    end

    def show
      # rest destroy falls back to rest show in case of disabled javascript
      # just render action_confirmation message for destroy
      unless params.delete :destroy_action
        do_show
        respond_to_action(:show)
      else
        @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id].to_i > 0
        action_confirmation_respond_to_html(:destroy)
      end
    end

    protected

    def show_respond_to_json
      render :text => response_object.to_json(:only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names)), :content_type => Mime::JSON, :status => response_status
    end

    def show_respond_to_yaml
      render :text => Hash.from_xml(response_object.to_xml(:only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names))).to_yaml, :content_type => Mime::YAML, :status => response_status
    end

    def show_respond_to_xml
      render :xml => response_object.to_xml(:only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names)), :content_type => Mime::XML, :status => response_status
    end

    def show_respond_to_js
      render :partial => 'show'
    end

    def show_respond_to_html
      render :action => 'show'
    end

    def show_columns_names
      active_scaffold_config.show.columns.names
    end

    # A simple method to retrieve and prepare a record for showing.
    # May be overridden to customize show routine
    def do_show
      set_includes_for_columns(:show) if active_scaffold_config.actions.include? :list
      klass = beginning_of_chain.includes(active_scaffold_includes)
      @record = find_if_allowed(params[:id], :read, klass)
    end

    # The default security delegates to ActiveRecordPermissions.
    # You may override the method to customize.
    def show_authorized?(record = nil)
      (record || self).send(:authorized_for?, :crud_type => :read)
    end
    def show_ignore?(record = nil)
      !self.send(:authorized_for?, :crud_type => :read)
    end
    private
    def show_authorized_filter
      link = active_scaffold_config.show.link || active_scaffold_config.show.class.link<commit_msg>use active_scaffold_preload instead of active_scaffold_includes<commit_after>module ActiveScaffold::Actions
  module Show
    def self.included(base)
      base.before_filter :show_authorized_filter, :only => :show
    end

    def show
      # rest destroy falls back to rest show in case of disabled javascript
      # just render action_confirmation message for destroy
      unless params.delete :destroy_action
        do_show
        respond_to_action(:show)
      else
        @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id].to_i > 0
        action_confirmation_respond_to_html(:destroy)
      end
    end

    protected

    def show_respond_to_json
      render :text => response_object.to_json(:only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names)), :content_type => Mime::JSON, :status => response_status
    end

    def show_respond_to_yaml
      render :text => Hash.from_xml(response_object.to_xml(:only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names))).to_yaml, :content_type => Mime::YAML, :status => response_status
    end

    def show_respond_to_xml
      render :xml => response_object.to_xml(:only => show_columns_names + [active_scaffold_config.model.primary_key], :include => association_columns(show_columns_names), :methods => virtual_columns(show_columns_names)), :content_type => Mime::XML, :status => response_status
    end

    def show_respond_to_js
      render :partial => 'show'
    end

    def show_respond_to_html
      render :action => 'show'
    end

    def show_columns_names
      active_scaffold_config.show.columns.names
    end

    # A simple method to retrieve and prepare a record for showing.
    # May be overridden to customize show routine
    def do_show
      set_includes_for_columns(:show) if active_scaffold_config.actions.include? :list
      klass = beginning_of_chain.preload(active_scaffold_preload)
      @record = find_if_allowed(params[:id], :read, klass)
    end

    # The default security delegates to ActiveRecordPermissions.
    # You may override the method to customize.
    def show_authorized?(record = nil)
      (record || self).send(:authorized_for?, :crud_type => :read)
    end
    def show_ignore?(record = nil)
      !self.send(:authorized_for?, :crud_type => :read)
    end
    private
    def show_authorized_filter
      link = active_scaffold_config.show.link || active_scaffold_config.show.class.link
{'fraction_non_alphanumeric': 0.09035687167805619, 'fraction_numerical': 0.00037965072133637056, 'mean_word_length': 4.071222329162657, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '7230649', 'n_tokens_mistral': 1576, 'n_tokens_neox': 1545, 'n_words': 357}