Sha256: df3414f7a34284cb79040bdda37fe6470f6a962fdc95282808b67bf0e06d6705

Contents?: true

Size: 554 Bytes

Versions: 1

Compression:

Stored size: 554 Bytes

Contents

class ItemsController < ApplicationController
  def index
    @items = Item.all
  end

  def new
    @item = Item.new
  end

  def create
    @item = Item.new(items_params)
    if @item.save
      redirect_to items_path
    else
      render :new
    end
  end

  def edit
    @item = Item.find(params[:id])
  end

  def update
    @item = Item.find(params[:id])
    if @item.update_attributes(items_params)
      redirect_to items_path
    else
      render :edit
    end
  end

  private

  def items_params
    params.require(:item).permit!
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
token_field-2.0.0 spec/dummy/app/controllers/items_controller.rb