Compare commits

..

No commits in common. "CRUD1" and "master" have entirely different histories.

3 changed files with 4 additions and 20 deletions

19
app.rb
View file

@ -11,7 +11,6 @@ require_relative 'models/assistant'
class App < Roda class App < Roda
plugin :render, escape: true plugin :render, escape: true
plugin :sessions, secret: ENV.delete('APP_SESSION_SECRET') plugin :sessions, secret: ENV.delete('APP_SESSION_SECRET')
plugin :all_verbs
route do |r| route do |r|
r.root do r.root do
@ -28,7 +27,6 @@ class App < Roda
@assistant = Assistant.new @assistant = Assistant.new
view :edit view :edit
end end
r.post do r.post do
@assistant = Assistant.new(r.params) @assistant = Assistant.new(r.params)
if @assistant.save if @assistant.save
@ -37,23 +35,6 @@ class App < Roda
r.halt(404) r.halt(404)
end end
end end
# Delete route
r.delete 'delete/:id' do
assistant = Assistant.find(params[:id])
if assistant
assistant.destroy
r.redirect '/'
else
r.halt(404)
end
end
# View route
r.get 'view', :id do
@assistant = Assistant.find(params[:id])
"#{@assistant}"
end
end end
end end
end end

View file

@ -17,4 +17,8 @@ class Assistant < Sequel::Model
def self.find_by_name(name) def self.find_by_name(name)
where(name: name).first where(name: name).first
end end
def self.active
where(active: true)
end
end end

View file

@ -25,7 +25,6 @@
<td><%= assistant.eval_rate || 'N/A' %></td> <td><%= assistant.eval_rate || 'N/A' %></td>
<td><%= assistant.capabilities || 'N/A' %></td> <td><%= assistant.capabilities || 'N/A' %></td>
<td><%= assistant.created_at.strftime('%Y-%m-%d %H:%M') if assistant.created_at %></td> <td><%= assistant.created_at.strftime('%Y-%m-%d %H:%M') if assistant.created_at %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>