Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Has anyone else had an issue getting the put and delete challenge to pass? Is my answer incorrect or is there a bug?

In Building Web Apps with Sinatra, Challenge Task 4 of 6, it states:

Now we need a Sinatra route to accept the DELETE request. Set up a delete route that will match any path with a format like /signatures/0, /signatures/1, /signatures/5, etc. The numeric part of the path should be captured in a URL parameter named index.

My code:

require "sinatra"

def load_signature(index)
  # Code omitted for brevity

def save_signature(signature)
  # Code omitted for brevity

def update_signature(index, signature)
  # Code omitted for brevity

# 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
  File.open("signatures.txt", "w") do |file|
    file.puts lines

get "/signatures/new" do
  # Code omitted for brevity

get "/signatures/:index" do
  @index = params[:index]
  @signature = load_signature(@index)
  erb 'show'.to_sym

delete "/signatures/:index" do


1 Answer

Jay McGavren
Jay McGavren
Treehouse Teacher

There was an error with this challenge that we just fixed. Try again now. Your code should pass as-is.

In the future, if you suspect an issue with the code challenge itself, please let us know! You can click the "Support" link at the top of any page to contact Treehouse Support. They will notify the appropriate teacher.

Sorry for the trouble!