diff --git a/app.rb b/app.rb index 9046286..e8c4fdb 100644 --- a/app.rb +++ b/app.rb @@ -11,26 +11,11 @@ class App < Roda check_csrf! r.root do - @page_title = 'Homepage' - @subtitle = 'My Homepage' + @page_title = 'Assistants List' + @subtitle = 'All ASsistants in Database' # renders index.erb inside layout.erb view :index 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 diff --git a/db/migrations/0001_create_models_table.rb b/db/migrations/0001_create_assistants.rb similarity index 92% rename from db/migrations/0001_create_models_table.rb rename to db/migrations/0001_create_assistants.rb index 3f6f1de..a353b95 100644 --- a/db/migrations/0001_create_models_table.rb +++ b/db/migrations/0001_create_assistants.rb @@ -2,7 +2,7 @@ Sequel.migration do change do - create_table(:models) do + create_table(:assistants) do primary_key :id String :name, null: false String :run_command, null: false, unique: true diff --git a/models/assistant.rb b/models/assistant.rb new file mode 100644 index 0000000..9c5730f --- /dev/null +++ b/models/assistant.rb @@ -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 \ No newline at end of file diff --git a/views/index.erb b/views/index.erb index 61f8563..d83f99a 100644 --- a/views/index.erb +++ b/views/index.erb @@ -1 +1 @@ -
<%= @subtitle %>
+