<commit_before># Responsible for managing the lifeblood of this application, recipes.
class RecipesController < ApplicationController
  respond_to :html, :xml, :json
  attr_reader :all_categories
  before_filter :get_all_categories # Only get the list of categories once.
  attr_reader :current_category
  attr_reader :author_name
  load_and_authorize_resource

  def index
    if user_signed_in?
      @recipes = Recipe.public_or_user current_user
    else
      @recipes = Recipe.public_only
    end
    respond_with(@recipes)
  end

  def show
    get_current_category
    get_author_name
    respond_with(@recipe)
  end

  def new
    setup_defaults
    respond_with(@recipe)
  end

  def edit
    respond_with(@recipe)
  end

  def create
    @recipe.user_id = user_signed_in? ? current_user.id : 0
    if !@recipe.picture[0].data
      @recipe.picture.delete_all
    end
    flash[:notice] = 'Recipe was successfully created.' if @recipe.save
    respond_with(@recipe)
  end

  def update
    @recipe.update_attributes(params[:recipe])
    respond_with(@recipe)
  end

  def destroy
    @recipe.destroy
    flash[:notice] = 'Successfully destroyed recipe.'
    respond_with(@recipe)
  end
<commit_msg>Only remove the blank picture collection if there are blank items. Save pictures if there is at least one with valid data.<commit_after># Responsible for managing the lifeblood of this application, recipes.
class RecipesController < ApplicationController
  respond_to :html, :xml, :json
  attr_reader :all_categories
  before_filter :get_all_categories # Only get the list of categories once.
  attr_reader :current_category
  attr_reader :author_name
  load_and_authorize_resource

  def index
    if user_signed_in?
      @recipes = Recipe.public_or_user current_user
    else
      @recipes = Recipe.public_only
    end
    respond_with(@recipes)
  end

  def show
    get_current_category
    get_author_name
    respond_with(@recipe)
  end

  def new
    setup_defaults
    respond_with(@recipe)
  end

  def edit
    respond_with(@recipe)
  end

  def create
    @recipe.user_id = user_signed_in? ? current_user.id : 0
    @recipe.picture.delete_all if @recipe.picture.size > 0 && !@recipe.picture[0].data
    flash[:notice] = 'Recipe was successfully created.' if @recipe.save
    respond_with(@recipe)
  end

  def update
    @recipe.update_attributes(params[:recipe])
    respond_with(@recipe)
  end

  def destroy
    @recipe.destroy
    flash[:notice] = 'Successfully destroyed recipe.'
    respond_with(@recipe)
  end

{'fraction_non_alphanumeric': 0.0717382735514387, 'fraction_numerical': 0.001970831690973591, 'mean_word_length': 3.6568807339449543, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5308592', 'n_tokens_mistral': 813, 'n_tokens_neox': 791, 'n_words': 210}