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