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! While you're at it, check out some resources Treehouse students have shared here.

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

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.