<commit_before># frozen_string_literal: true
class FinancialTransactionsController < ApplicationController
  before_action :set_financial_transaction, only: [:show, :edit, :update]

  # GET /financial_transactions
  def index
    @q = FinancialTransaction.search(params[:q])
    @trans_type = FinancialTransaction.all.pluck(:transactable_type).uniq
    @financial_transactions = @q.result.paginate(page: params[:page], per_page: 10)
  end

  # GET /financial_transactions/1
  def show
  end

  # only really handles transactable_type payment
  def new
    @financial_transaction = FinancialTransaction.new
    @financial_transaction.rental = Rental.find(params.require(:rental_id))
    @financial_transaction.transactable_type = params[:transactable_type]
    if @financial_transaction.transactable_type != Payment 
      @financial_transaction.transactable_id = params[:transactable_id]
    end
    if !@financial_transaction.rental
      flash[:danger] = 'A rental has not been found for this financial transaction.'
    end
  end

  # GET /financial_transactions/1/edit
  def edit
  end

  # POST /financial_transactions
  def create
    @financial_transaction = FinancialTransaction.new(financial_transaction_params)

    if @financial_transaction.transactable_type == Payment
      payment = Payment.create!(payment_params) # hard fail
      @financial_transaction.transactable_id = payment.id
    end

    if @financial_transaction.save
      redirect_to rental_invoice_path(@financial_transaction.rental_id), success: 'Financial transaction was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /financial_transactions/1
  def update
    if @financial_transaction.update(financial_transaction_params)
      redirect_to @financial_transaction, success: 'Financial transaction was successfully updated.'
    else
      render :edit
    end
  end

  private

    # Use callbacks to share common setup or constraints between actions.
    def set_financial_transaction
      @financial_transaction = FinancialTransaction.find(params[:id])
    end
<commit_msg>have to compare name to name<commit_after># frozen_string_literal: true
class FinancialTransactionsController < ApplicationController
  before_action :set_financial_transaction, only: [:show, :edit, :update]

  # GET /financial_transactions
  def index
    @q = FinancialTransaction.search(params[:q])
    @trans_type = FinancialTransaction.all.pluck(:transactable_type).uniq
    @financial_transactions = @q.result.paginate(page: params[:page], per_page: 10)
  end

  # GET /financial_transactions/1
  def show
  end

  # only really handles transactable_type payment
  def new
    @financial_transaction = FinancialTransaction.new
    @financial_transaction.rental = Rental.find(params.require(:rental_id))
    @financial_transaction.transactable_type = params[:transactable_type]
    if @financial_transaction.transactable_type != Payment.name
      @financial_transaction.transactable_id = params[:transactable_id]
    end
    if !@financial_transaction.rental
      flash[:danger] = 'A rental has not been found for this financial transaction.'
    end
  end

  # GET /financial_transactions/1/edit
  def edit
  end

  # POST /financial_transactions
  def create
    @financial_transaction = FinancialTransaction.new(financial_transaction_params)

    if @financial_transaction.transactable_type == Payment.name
      payment = Payment.create!(payment_params) # hard fail
      @financial_transaction.transactable_id = payment.id
    end

    if @financial_transaction.save
      redirect_to rental_invoice_path(@financial_transaction.rental_id), success: 'Financial transaction was successfully created.'
    else
      render :new
    end
  end

  # PATCH/PUT /financial_transactions/1
  def update
    if @financial_transaction.update(financial_transaction_params)
      redirect_to @financial_transaction, success: 'Financial transaction was successfully updated.'
    else
      render :edit
    end
  end

  private

    # Use callbacks to share common setup or constraints between actions.
    def set_financial_transaction
      @financial_transaction = FinancialTransaction.find(params[:id])
    end

{'fraction_non_alphanumeric': 0.07278782112274025, 'fraction_numerical': 0.002378686964795433, 'mean_word_length': 4.356687898089172, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '5390585', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1179, 'n_words': 277}