raven/lib/routes.rb

47 lines
925 B
Ruby
Raw Normal View History

2022-12-07 17:52:27 -05:00
get '/' do
items = Item.all
erb :index, :locals => {
:title => 'Dashboard',
:items => items
}
end
2022-12-07 20:12:23 -05:00
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
get '/item/:item_id' do
item = Item.where(id: params[:item_id]).first
puts "#{item.name}"
erb :'item/view', :locals => {
:title => item.name,
:item => item
}
end