Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Building Web Apps with Sinatra Updating Data An Edit Form

MaryAnn Eleanya
MaryAnn Eleanya
8,626 Points

I am not sure what I am doing wrong in this project.

I'm having a hard time rendering the required file.

guestbook.rb
require "sinatra"

views/edit.erb
def load_signature(index)
  lines = File.readlines("signatures.txt")
  # Parameter is a string; convert to integer
  index = index.to_i
  lines[index]
end

get "/:index/edit" do
  @index = params[:index]
 @signature = load_signature(@index)
erb :index
end
views/edit.erb
<p>Please enter your name below.</p>

<form>
  <input type="text" name="signature" value="<%= %>">
  <input type="submit">
</form>

1 Answer

Hi there,

You want to render the :edit not the :index. :smile:

Steve.