Christopher Phillips10,049 Points
What am I doing wrong?
I'm supposed to create a DELETE route path which will delete "/signatures/:index"
As you can see with my code, I don't think I'm doing anything wrong. But I've gone through a few of these challenges now and have had to skip them because I've always been getting an error when creating my routes. Thus, I think I'm doing it wrong. Can someone please shed some light on the subject for me??
<p><%= @signature %></p> <form method="post" action="/signatures/<%= @index %>"> <input type="hidden" name="_method" value="delete"> <input type="submit" value="Delete This Signature"/> </form>
require "sinatra" def load_signature(index) # Code omitted for brevity end def save_signature(signature) # Code omitted for brevity end def update_signature(index, signature) # Code omitted for brevity end # Deletes the line at the given index and re-saves the file. def delete_signature(index) lines = File.readlines("signatures.txt") index = index.to_i lines.delete_at(index) File.open("signatures.txt", "w") do |file| file.puts lines end end get "/signatures/new" do # Code omitted for brevity end get "/signatures/:index" do @index = params[:index] @signature = load_signature(@index) erb 'show'.to_sym end delete "/signatures/:index" do end
Jay McGavrenTreehouse Teacher
It looks like some changes we made on the code challenge runner broke this challenge. That should now be fixed, and your code should pass up through Task 4 as-is. Sorry for the trouble!