diff --git a/web_dev/sinatra_templating/app.rb b/web_dev/sinatra_templating/app.rb index 838000c9b3d..781a9a9bf96 100644 --- a/web_dev/sinatra_templating/app.rb +++ b/web_dev/sinatra_templating/app.rb @@ -17,6 +17,12 @@ erb :new_student end +get '/students/delete' do + @students = db.execute("SELECT * FROM students") + erb :delete_student +end + + # create new students via # a form post '/students' do @@ -24,4 +30,13 @@ redirect '/' end -# add static resources \ No newline at end of file +# add static resources + +# create a Route for delete_student + +get '/delete-student' do ## seems to work the same way with GET or POST + db.execute("DELETE FROM students WHERE id = ?", [params['id']]) + redirect '/' +end + + diff --git a/web_dev/sinatra_templating/students.db b/web_dev/sinatra_templating/students.db index a276be081a8..13baa3a9357 100644 Binary files a/web_dev/sinatra_templating/students.db and b/web_dev/sinatra_templating/students.db differ diff --git a/web_dev/sinatra_templating/views/delete_student.erb b/web_dev/sinatra_templating/views/delete_student.erb new file mode 100644 index 00000000000..63b354d0a41 --- /dev/null +++ b/web_dev/sinatra_templating/views/delete_student.erb @@ -0,0 +1,21 @@ + + +
+Enter the id number of the student you want to delete.
+ + +Welcome to the student management system.
-Click here to create a new student.
+Click here to create a new student, or here to delete a student.