<commit_before>class HitchhikesController < ApplicationController
  before_filter :authenticate_user!, :except => [:show]
  
  def index
    @hitchhikes = Hitchhike.where(:user_id => current_user.id)
    respond_to do |wants|
      wants.html
      wants.json do
        if params[:id]
          render :json => Hitchhike.find(params[:id]).to_json
        else
          render :json => Hitchhike.order('RAND()').first.to_json
        end
      end
    end
  end

  def show
    @hitchhike = Hitchhike.find(params[:id])
    respond_to do |wants|
      wants.html
      wants.json { render :json => @hitchhike.to_json }
    end
  end
  
  def new
    @hitchhike = Hitchhike.new
    @hitchhike.people.build
  end

  def create
    @hitchhike = Hitchhike.new(params[:hitchhike])
    @hitchhike.user = current_user
    if @hitchhike.save
      if params[:hitchhike][:photo].blank?
        flash[:notice] = "Successfully created hitchhike."
        redirect_to @hitchhike
      else
        render :action => "crop"
      end
    else
      render :action => 'new'
    end
  end
  
  def edit
    @hitchhike = Hitchhike.find(params[:id])
  end
  
  def update
    @hitchhike = Hitchhike.find(params[:id])
    if @hitchhike.update_attributes(params[:hitchhike])
      if params[:hitchhike][:photo].blank?
        flash[:notice] = "Successfully updated hitchhike."
        redirect_to @hitchhike
      else
        render :action => "crop"
      end
    else
      render :action => 'edit'
    end
  end
  
  def destroy
    @hitchhike = Hitchhike.find(params[:id])
    @hitchhike.destroy
    flash[:notice] = "Successfully destroyed hitchhike."
    redirect_to hitchhikes_url
  end
end
<commit_msg>fixed authentication error<commit_after>class HitchhikesController < ApplicationController
  before_filter :authenticate_user!, :except => [:show, :index]
  
  def index
    respond_to do |wants|
      wants.html do
        @hitchhikes = current_user.hitchhikes
      end
      wants.json do
        if params[:id]
          render :json => Hitchhike.find(params[:id]).to_json
        else
          render :json => Hitchhike.order('RAND()').first.to_json
        end
      end
    end
  end

  def show
    @hitchhike = Hitchhike.find(params[:id])
    respond_to do |wants|
      wants.html
      wants.json { render :json => @hitchhike.to_json }
    end
  end
  
  def new
    @hitchhike = Hitchhike.new
    @hitchhike.people.build
  end

  def create
    @hitchhike = Hitchhike.new(params[:hitchhike])
    @hitchhike.user = current_user
    if @hitchhike.save
      if params[:hitchhike][:photo].blank?
        flash[:notice] = "Successfully created hitchhike."
        redirect_to @hitchhike
      else
        render :action => "crop"
      end
    else
      render :action => 'new'
    end
  end
  
  def edit
    @hitchhike = Hitchhike.find(params[:id])
  end
  
  def update
    @hitchhike = Hitchhike.find(params[:id])
    if @hitchhike.update_attributes(params[:hitchhike])
      if params[:hitchhike][:photo].blank?
        flash[:notice] = "Successfully updated hitchhike."
        redirect_to @hitchhike
      else
        render :action => "crop"
      end
    else
      render :action => 'edit'
    end
  end
  
  def destroy
    @hitchhike = Hitchhike.find(params[:id])
    @hitchhike.destroy
    flash[:notice] = "Successfully destroyed hitchhike."
    redirect_to hitchhikes_url
  end
end

{'fraction_non_alphanumeric': 0.10526315789473684, 'fraction_numerical': 0.0, 'mean_word_length': 2.5108359133126936, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, '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': '237673', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1157, 'n_words': 246}