<commit_before>class TicketsController < ApplicationController
  
  def new
    @ticket = Ticket.new
    @show = Show.find(params[:show_id])
  end

  def create
    byebug
    @ticket = Ticket.new(ticket_params)
    @show = Show.find(params[:show_id])
    if @ticket.save
      TicketMailer.ticket_purchase(@ticket).deliver
      redirect_to show_ticket_path(@show.id, @ticket.id)
    else
      @errors = @ticket.errors.full_messages
      render 'tickets/new'
    end
  end

  def show
    @ticket = Ticket.find(params[:id])
    @show = Show.find(params[:show_id])
  end

  private

  def ticket_params
    params.require(:ticket).permit(:first_name, :last_name, :email_address, :credit_card_number, :credit_card_expiration_date) 
  end

end<commit_msg>add mailer method to ticket create and fix create method to add show_id to a ticket<commit_after>class TicketsController < ApplicationController
  
  def new
    @ticket = Ticket.new
    @show = Show.find(params[:show_id])
  end

  def create
    @ticket = Ticket.new(ticket_params)
    @show = Show.find(params[:show_id])
    @ticket.show_id = @show.id
    if @ticket.save
      TicketMailer.ticket_receipt(@ticket).deliver_now
      redirect_to show_ticket_path(@show.id, @ticket.id)
    else
      @errors = @ticket.errors.full_messages
      render 'tickets/new'
    end
  end

  def show
    @ticket = Ticket.find(params[:id])
    @show = Show.find(params[:show_id])
  end

  private

  def ticket_params
    params.require(:ticket).permit(:first_name, :last_name, :email_address, :credit_card_number, :credit_card_expiration_date) 
  end

end
{'fraction_non_alphanumeric': 0.10542732376793512, 'fraction_numerical': 0.0, 'mean_word_length': 3.5828571428571427, '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': '1868714', 'n_tokens_mistral': 572, 'n_tokens_neox': 532, 'n_words': 109}