renamed models to assistants to not confuse with sequel models

This commit is contained in:
James Dinkel 2025-08-20 00:38:33 -05:00
parent 5e3557cb63
commit f738766931
4 changed files with 28 additions and 19 deletions

19
app.rb
View file

@ -11,26 +11,11 @@ class App < Roda
check_csrf! check_csrf!
r.root do r.root do
@page_title = 'Homepage' @page_title = 'Assistants List'
@subtitle = 'My Homepage' @subtitle = 'All ASsistants in Database'
# renders index.erb inside layout.erb # renders index.erb inside layout.erb
view :index view :index
end end
r.get 'about' do
@page_title = 'About page'
@subtitle = 'About This Site'
# renders about.erb inside layout.erb
view :index
end
r.on 'hello' do
r.get String do |name|
@name = name.capitalize
@subtitle = "Hello, #{@name}!"
view :index
end
end
end end
end end

View file

@ -2,7 +2,7 @@
Sequel.migration do Sequel.migration do
change do change do
create_table(:models) do create_table(:assistants) do
primary_key :id primary_key :id
String :name, null: false String :name, null: false
String :run_command, null: false, unique: true String :run_command, null: false, unique: true

24
models/assistant.rb Normal file
View file

@ -0,0 +1,24 @@
# app/models/assistant.rb
require 'sequel'
class Assistant < Sequel::Model
# This model assumes your assistants table has these columns:
# id (primary key), name, description, created_at, updated_at
# If you have a different schema, modify the column names accordingly
# Optional: Add validations
def validate
super
errors.add(:name, 'must be present') if name.nil? || name.empty?
end
# Optional: Add custom methods for common operations
def self.find_by_name(name)
where(name: name).first
end
def self.active
where(active: true)
end
end

View file

@ -1 +1 @@
<p class="subtitle"><%= @subtitle %></p> <h2 class="subtitle"><%= @subtitle %></h2>