<commit_before>class Admin::<%= controller_class_name %>Controller < Admin::BaseController

  helper_method :sort_column, :sort_direction, :search_params

  before_filter :find_<%= singular_table_name %>, :only => [:edit, :update, :show, :destroy]

  def index
    @search = <%= class_name %>.search(params[:search])
    search_relation = @search.relation
    @<%= plural_table_name %> =  search_relation.order(sort_column + " " + sort_direction).page params[:page]
  end

  def new
    @<%= singular_table_name %> = <%= class_name %>.new
  end

  def create
    @<%= singular_table_name %> = <%= class_name %>.new(params[:<%= singular_table_name %>])
    if @<%= singular_table_name %>.save
      redirect_to admin_<%= plural_table_name %>_path, :notice => "Successfully created <%= human_name.downcase %>."
    else
      render :new
    end
  end

  def show
  end

  def edit
  end

  def update
    if @<%= singular_table_name %>.update_attributes(params[:<%= singular_table_name %>])
      redirect_to admin_<%= plural_table_name %>_path, :notice => "Successfully updated <%= human_name.downcase %>."
    else
      render :edit
    end
  end

  def destroy
    @<%= singular_table_name %>.destroy
    redirect_to admin_<%= plural_table_name %>_path, :notice => "<%= human_name %> has been deleted."
  end

  protected

  def find_<%= singular_table_name %>
    @<%= singular_table_name %> = <%= class_name %>.find(params[:id])
  end

  def sort_column
    <%= class_name %>.column_names.include?(params[:sort]) ? params[:sort] : "created_at"
  end

  def sort_direction
    %w[asc desc].include?(params[:direction]) ? params[:direction] : "desc"
  end

  def search_params
    {:search => params[:search]}
  end

end<commit_msg>Restore the find_<%= plural %> encapsulation.<commit_after>class Admin::<%= controller_class_name %>Controller < Admin::BaseController

  helper_method :sort_column, :sort_direction, :search_params

  before_filter :find_<%= singular_table_name %>, :only => [:edit, :update, :show, :destroy]

  def index
    @search = <%= class_name %>.search(params[:search])
    @<%= plural_table_name %> = find_<%= plural_table_name %>
  end

  def new
    @<%= singular_table_name %> = <%= class_name %>.new
  end

  def create
    @<%= singular_table_name %> = <%= class_name %>.new(params[:<%= singular_table_name %>])
    if @<%= singular_table_name %>.save
      redirect_to admin_<%= plural_table_name %>_path, :notice => "Successfully created <%= human_name.downcase %>."
    else
      render :new
    end
  end

  def show
  end

  def edit
  end

  def update
    if @<%= singular_table_name %>.update_attributes(params[:<%= singular_table_name %>])
      redirect_to admin_<%= plural_table_name %>_path, :notice => "Successfully updated <%= human_name.downcase %>."
    else
      render :edit
    end
  end

  def destroy
    @<%= singular_table_name %>.destroy
    redirect_to admin_<%= plural_table_name %>_path, :notice => "<%= human_name %> has been deleted."
  end

  protected

  def find_<%= singular_table_name %>
    @<%= singular_table_name %> = <%= class_name %>.find(params[:id])
  end

  def find_<%= plural_table_name %>
    search_relation = @search.relation
    search_relation.order(sort_column + " " + sort_direction).page params[:page]
  end

  def sort_column
    <%= class_name %>.column_names.include?(params[:sort]) ? params[:sort] : "created_at"
  end

  def sort_direction
    %w[asc desc].include?(params[:direction]) ? params[:direction] : "desc"
  end

  def search_params
    {:search => params[:search]}
  end

end
{'fraction_non_alphanumeric': 0.15036333147009504, 'fraction_numerical': 0.0, 'mean_word_length': 4.019635343618513, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 62, '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': '3816934', 'n_tokens_mistral': 1258, 'n_tokens_neox': 1141, 'n_words': 257}