<commit_before>class StoriesController < ApplicationController

  def new
    @stories = Story.find_recent(5)
    @title = t :new_story
    @story = Story.new()
  end
  
  def index
    @title = t(:recent_stories)
    @stories = Story.paginate( :page => params[:page], 
                                  :conditions => ['confirmed = ?', true],
                                  :order => 'created_at DESC' )
    respond_to do |format|
      format.html
      format.atom { render :action => 'index.atom.builder', :layout => false }
    end
  end
  
  def find
    @location_search = LocationSearch.new_search!(session_id, params)
    story_attributes = params[:story]
    story_attributes[:location_search] = @location_search
    @story = Story.new(story_attributes)
    if !@story.valid? 
      @title = t :new_story
      render :new
    else
      @story.location_from_attributes
      if @story.locations.size == 1
         redirect_to location_url(@story.locations.first)
      elsif !@story.locations.empty?
        @story.locations = @story.locations.sort_by(&:name)
        location_search.add_choice(@story.locations)
        @title = t :multiple_locations
        render :choose_location
      else
        @title = t :new_story
        render :new
      end
    end
  end
  
  def choose_location
  end
  
  def confirm
    @story = Story.find_by_token(params[:email_token])
    if !@story
      @error = t(:story_not_found)
    else
      @story.toggle!(:confirmed)
    end
  end
  
  def show
    @story = Story.find(params[:id])
    @title = @story.subject
  end
  
  private
  
  rescue_from ActiveRecord::RecordNotFound do
    render :file => "#{RAILS_ROOT}/public/404.html", :status => :not_found
  end
  
end<commit_msg>Make sure recent stories appear on submit fail<commit_after>class StoriesController < ApplicationController

  def new
    @stories = Story.find_recent(5)
    @title = t :new_story
    @story = Story.new()
  end
  
  def index
    @title = t(:recent_stories)
    @stories = Story.paginate( :page => params[:page], 
                                  :conditions => ['confirmed = ?', true],
                                  :order => 'created_at DESC' )
    respond_to do |format|
      format.html
      format.atom { render :action => 'index.atom.builder', :layout => false }
    end
  end
  
  def find
    @location_search = LocationSearch.new_search!(session_id, params)
    story_attributes = params[:story]
    story_attributes[:location_search] = @location_search
    @story = Story.new(story_attributes)
    if !@story.valid? 
      @title = t :new_story
      render :new
    else
      @story.location_from_attributes
      if @story.locations.size == 1
         redirect_to location_url(@story.locations.first)
      elsif !@story.locations.empty?
        @story.locations = @story.locations.sort_by(&:name)
        location_search.add_choice(@story.locations)
        @title = t :multiple_locations
        render :choose_location
      else
        @stories = Story.find_recent(5)
        @title = t :new_story
        render :new
      end
    end
  end
  
  def choose_location
  end
  
  def confirm
    @story = Story.find_by_token(params[:email_token])
    if !@story
      @error = t(:story_not_found)
    else
      @story.toggle!(:confirmed)
    end
  end
  
  def show
    @story = Story.find(params[:id])
    @title = @story.subject
  end
  
  private
  
  rescue_from ActiveRecord::RecordNotFound do
    render :file => "#{RAILS_ROOT}/public/404.html", :status => :not_found
  end
  
end
{'fraction_non_alphanumeric': 0.10679064525218371, 'fraction_numerical': 0.0030994646379261764, 'mean_word_length': 2.4332688588007736, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6871592', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1087, 'n_words': 240}