<commit_before>class SoundTreksController < ApplicationController
  include SoundTreksHelper

  def index

  end

  def show
    @sound_trek = SoundTrek.find(params[:id])
  end

  def new
    # @sound_trek = SoundTrek.new
  end

  def edit
    @sound_trek = SoundTrek.find(params[:id])
  end

  def create
    @sound_trek = SoundTrek.new(sound_trek_params)
    if @sound_trek.save
      redirect_to @sound_trek
    else
      @errors = @sound_trek.errors.full_messages
      render "new"
    end
  end

  def update
    @sound_trek = SoundTrek.find(params[:id])
     if @sound_trek.update(sound_trek_params)
      redirect_to @sound_trek
    else
      render 'edit'
    end

        # if sound_trek_owner?(@sound_trek)

    # else
      # flash[:no_access] = "You do not have permission to edit this SoundTrek."        redirect_to @recipe
      # redirect_to @sound_trek
    # end
  end


  # def destroy
  # end


  private
  def sound_trek_params
    params.require(:sound_trek).permit(:description, :title, :location_id, :playlist_id)
  end
end
<commit_msg>Add destroy action so that a creator can delete their soundtrek<commit_after>class SoundTreksController < ApplicationController
  include SoundTreksHelper

  def index

  end

  def show
    @sound_trek = SoundTrek.find(params[:id])
  end

  def new
    # @sound_trek = SoundTrek.new
  end

  def edit
    # Fix this shit
    @sound_trek = SoundTrek.find(params[:id])
    if sound_trek_owner?(@sound_trek)
      @sound_trek
    end
  end

  def create
    @sound_trek = SoundTrek.new(sound_trek_params)
    if @sound_trek.save
      redirect_to @sound_trek
    else
      @errors = @sound_trek.errors.full_messages
      render "new"
    end
  end

  def update
    @sound_trek = SoundTrek.find(params[:id])
    if sound_trek_owner?(@sound_trek)
     if @sound_trek.update(sound_trek_params)
      redirect_to @sound_trek
    else
      render 'edit'
    end

        # if sound_trek_owner?(@sound_trek)

    # else
      # flash[:no_access] = "You do not have permission to edit this SoundTrek."        redirect_to @recipe
      # redirect_to @sound_trek
    end
  end


  def destroy
    @sound_trek = SoundTrek.find(params[:id])

    if sound_trek_owner?(@sound_trek)
      @sound_trek.destroy
      redirect_to user_path(session[:user_id])
    else
      flash[:no_access] = "You do not have permission to delete this SoundTrek."
      redirect_to @sound_trek
    end
  end

  private
  def sound_trek_params
    params.require(:sound_trek).permit(:description, :title, :location_id, :playlist_id)
  end
end

{'fraction_non_alphanumeric': 0.08161678973960358, 'fraction_numerical': 0.0, 'mean_word_length': 2.96, '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': '3093578', 'n_tokens_mistral': 914, 'n_tokens_neox': 883, 'n_words': 202}