<commit_before>class ItemsController < ApplicationController
  def index
  end

  def show
  end

  def new
    @list = List.find_by(id: params[:list_id])
    @item = @list.items.build
    @store = Store.new
  end

  def edit
    @list = List.find_by(id: params[:list_id])
    @item = Item.find_by(id: params[:id])
    @store = @item.store
    render :edit
  end

  def create
<<<<<<< Updated upstream
    list = List.find_by(id: params[:list_id])
    store = Store.find_or_create_by(store_params)
    item = list.items.create(name: params[:item][:name], store_id: store.id)
=======
<<<<<<< Updated upstream
    Item.create(item_params)
=======
    list = List.find_by(id: params[:list_id])
    store = Store.find_or_create_by(store_params)
    item = list.items.create(name: params[:item][:name], quantity: params[:item][:quantity], store_id: store.id)
>>>>>>> Stashed changes
    if item.valid?
      redirect_to list_path(list)
    else
      render :new
    end
<<<<<<< Updated upstream
=======
>>>>>>> Stashed changes
>>>>>>> Stashed changes
  end

  def update
    list = List.find_by(id: params[:list_id])
    item = Item.find_by(id: params[:id])
    store = Store.find_by(store_params)
    if item.update_attributes(name: params[:item][:name], store_id: store.id)#name: params[:item][:name])
      redirect_to list_path(list)
    else
      render :edit
    end<commit_msg>Specify qty when editing Item<commit_after>class ItemsController < ApplicationController
  def index
  end

  def show
  end

  def new
    @list = List.find_by(id: params[:list_id])
    @item = @list.items.build
    @store = Store.new
  end

  def edit
    @list = List.find_by(id: params[:list_id])
    @item = Item.find_by(id: params[:id])
    @store = @item.store
    render :edit
  end

  def create
    list = List.find_by(id: params[:list_id])
    store = Store.find_or_create_by(store_params)
    item = list.items.create(name: params[:item][:name], quantity: params[:item][:quantity], store_id: store.id)
    if item.valid?
      redirect_to list_path(list)
    else
      render :new
    end
  end

  def update
    list = List.find_by(id: params[:list_id])
    item = Item.find_by(id: params[:id])
    store = Store.find_by(store_params)
    if item.update_attributes(name: params[:item][:name], quantity: params[:item][:quantity], store_id: store.id)
      redirect_to list_path(list)
    else
      render :edit
    end
{'fraction_non_alphanumeric': 0.14504765851636967, 'fraction_numerical': 0.0, 'mean_word_length': 3.5461393596986817, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 24, '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': '955057', 'n_tokens_mistral': 841, 'n_tokens_neox': 819, 'n_words': 181}