From f71f8c57afe5b2d95e8692afbc8629d9af4becd5 Mon Sep 17 00:00:00 2001 From: kenney-g Date: Mon, 14 Sep 2020 23:09:14 -0400 Subject: [PATCH] All routes and controllers debugged and working --- app/controllers/application_controller.rb | 8 ++-- app/controllers/logs_controller.rb | 12 +++--- app/views/layout.erb | 6 +-- app/views/logs/show.erb | 43 +++++++++------------- app/views/users/index.erb | 3 +- db/development.sqlite | Bin 32768 -> 32768 bytes instructionds.md | 0 public/stylesheets/main.css | 2 +- spec.md | 2 +- 9 files changed, 33 insertions(+), 43 deletions(-) delete mode 100644 instructionds.md diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 12a2283..91bee09 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -16,10 +16,10 @@ class ApplicationController < Sinatra::Base erb :'welcome' end - not_found do - flash[:error] = "Whoops! Couldn't find that route" - redirect "/" - end + # not_found do + # flash[:error] = "I got lost, sorry. 404. Error beep boop bop." + # redirect "/" + # end private def current_user diff --git a/app/controllers/logs_controller.rb b/app/controllers/logs_controller.rb index ae820eb..9fa64d0 100644 --- a/app/controllers/logs_controller.rb +++ b/app/controllers/logs_controller.rb @@ -50,12 +50,11 @@ class LogsController < ApplicationController end end - # DELETE: /logs/5/delete - delete "/logs/:id/" do + #DELETE: /logs/5/delete + delete '/logs/:id' do set_log - redirect_if_not_authorized - @log.destroy - redirect "/logs" + @log.id = Log.delete(params[:id]) + redirect to("/users") end private @@ -64,12 +63,13 @@ def set_log @log = Log.find_by_id(params[:id]) if @log.nil? flash[:error] = "Couldn't find a log with id: #{params[:id]}" - redirect "/logs/" + redirect "/logs" end end def redirect_if_not_authorized + redirect_if_not_logged_in if !authorize_log(@log) flash[:error] = "You don't have permission to do that action" redirect "/logs" diff --git a/app/views/layout.erb b/app/views/layout.erb index bdfecf2..8472943 100644 --- a/app/views/layout.erb +++ b/app/views/layout.erb @@ -68,14 +68,12 @@ -->
- - Back to Top - +

This website was designed for Flatiron School's software development course.

- +