diff --git a/lib/routes.rb b/lib/routes.rb index 9aa4b1a..b317ed0 100644 --- a/lib/routes.rb +++ b/lib/routes.rb @@ -5,3 +5,33 @@ get '/' do :items => items } end + +get '/item' do + redirect '/item/list' +end +get '/item/list' do + items = Item.all + erb :'item/list', :locals => { + :title => 'List of Items', + :items => items + } +end + +get '/item/create' do + erb :'item/create', :locals => { + :title => 'Create New Item' + } +end +post '/item/create' do + item = Item.create( + name: params[:item_name], + serial_number: params[:item_serial], + sku_number: params[:item_sku], + purchased_from: params[:item_purchase_from], + purchased_at: params[:item_purchase_date], + manufacturer: params[:item_manufacturer], + type: params[:item_type] + ) + + redirect "/item/#{item.id}" +end diff --git a/views/item/create.erb b/views/item/create.erb new file mode 100644 index 0000000..b4deabf --- /dev/null +++ b/views/item/create.erb @@ -0,0 +1,64 @@ +