43 lines
911 B
Ruby
43 lines
911 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'roda'
|
|
require 'tilt'
|
|
require 'tilt/erubi'
|
|
|
|
require_relative 'db'
|
|
require_relative 'models/assistant'
|
|
|
|
# Listing large language models (aka "Assistants")
|
|
class App < Roda
|
|
plugin :render, escape: true
|
|
plugin :route_csrf
|
|
|
|
route do |r|
|
|
# check_csrf!
|
|
|
|
r.root do
|
|
@page_title = 'Assistants List'
|
|
@subtitle = 'All Assistants in Database'
|
|
@assistants = Assistant.all
|
|
# renders index.erb inside layout.erb
|
|
view :index
|
|
end
|
|
|
|
r.on 'assistants' do
|
|
r.get 'new' do
|
|
@page_title = 'Create New Assistant'
|
|
@assistant = Assistant.new
|
|
view :edit
|
|
end
|
|
r.post do
|
|
@assistant = Assistant.new(r.params)
|
|
if @assistant.save
|
|
r.redirect '/' # change to just r.redirect when get a host.org/assistants page up
|
|
else
|
|
r.halt(404)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|