<commit_before>class EquipmentObjectsController < ApplicationController
  before_filter :require_admin, :except => :index
  before_filter :require_checkout_person, :only => :index
  
  def index
    @equipment_objects = EquipmentObject.all
    if params[:equipment_model_id]
      @equipment_model = EquipmentModel.find(params[:equipment_model_id])
      @equipment_objects = @equipment_model.equipment_objects
    elsif params[:show_accessories]
      @equipment_objects = EquipmentObject.find(:all, :include => :equipment_model, :order => 'equipment_models.name ASC, equipment_objects.name ASC')
    else
      @equipment_objects = EquipmentObject.find(:all, :include => :equipment_model, :order => 'equipment_models.name ASC, equipment_objects.name ASC')
      @equipment_objects = @equipment_objects.select{|e| e.equipment_model.category.name != "Accessories"}
    end
  end
  
  def show
    @equipment_object = EquipmentObject.find(params[:id])
  end
  
  def new
    @equipment_model = EquipmentModel.find(params[:equipment_model_id]) if params[:equipment_model_id]
    @equipment_object = EquipmentObject.new(:equipment_model => @equipment_model)
  end
  
  def create
    @equipment_object = EquipmentObject.new(params[:equipment_object])
    @equipment_object.serial = nil if @equipment_object.serial = "Enter serial # (optional)"
    if @equipment_object.save
      flash[:notice] = "Successfully created equipment object."
      redirect_to @equipment_object.equipment_model
    else
      render :action => 'new'
    end
  end
  
  def edit
    @equipment_object = EquipmentObject.find(params[:id])
  end
  
  def update
    @equipment_object = EquipmentObject.find(params[:id])
    if @equipment_object.update_attributes(params[:equipment_object])
      flash[:notice] = "Successfully updated equipment object."
      redirect_to @equipment_object.equipment_model
    else
      render :action => 'edit'
    end
  end<commit_msg>serial numbers are now saved; control structure was causing issues<commit_after>class EquipmentObjectsController < ApplicationController
  before_filter :require_admin, :except => :index
  before_filter :require_checkout_person, :only => :index
  
  def index
    @equipment_objects = EquipmentObject.all
    if params[:equipment_model_id]
      @equipment_model = EquipmentModel.find(params[:equipment_model_id])
      @equipment_objects = @equipment_model.equipment_objects
    elsif params[:show_accessories]
      @equipment_objects = EquipmentObject.find(:all, :include => :equipment_model, :order => 'equipment_models.name ASC, equipment_objects.name ASC')
    else
      @equipment_objects = EquipmentObject.find(:all, :include => :equipment_model, :order => 'equipment_models.name ASC, equipment_objects.name ASC')
      @equipment_objects = @equipment_objects.select{|e| e.equipment_model.category.name != "Accessories"}
    end
  end
  
  def show
    @equipment_object = EquipmentObject.find(params[:id])
  end
  
  def new
    @equipment_model = EquipmentModel.find(params[:equipment_model_id]) if params[:equipment_model_id]
    @equipment_object = EquipmentObject.new(:equipment_model => @equipment_model)
  end
  
  def create
    @equipment_object = EquipmentObject.new(params[:equipment_object])
    # raise params.to_yaml
    if @equipment_object.serial == "Enter serial # (optional)"
      @equipment_object.serial = nil
    end
    if @equipment_object.save
      flash[:notice] = "Successfully created equipment object. #{@equipment_object.serial}"
      redirect_to @equipment_object.equipment_model
    else
      render :action => 'new'
    end
  end
  
  def edit
    @equipment_object = EquipmentObject.find(params[:id])
  end
  
  def update
    @equipment_object = EquipmentObject.find(params[:id])
    if @equipment_object.update_attributes(params[:equipment_object])
      flash[:notice] = "Successfully updated equipment object."
      redirect_to @equipment_object.equipment_model
    else
      render :action => 'edit'
    end
  end
{'fraction_non_alphanumeric': 0.09802943377400848, 'fraction_numerical': 0.0, 'mean_word_length': 4.470668485675307, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, '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': '3099213', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1181, 'n_words': 238}