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

why cant i get help somewhere rather than sit here

?

guestbook.rb
require "sinatra"

# Loads the signature at the given line index.
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)

end
views/edit.erb
<p>Please enter your name below.</p>

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

</form>

1 Answer

Dillon Wyatt
Dillon Wyatt
5,990 Points

I am not sure if this is what you are looking for or not, but you almost passed the challenge:

You have:

get "/:index/edit" do
  @index = params[:index]
  @signature = load_signature(@index)
end

Which is correct per the test.

You also have in the view

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

There is a <%= %> in the view. You need only give it the instance variable it needs. Instance variables are the ones with the @ mark before them. They are able to be sent between the Controller 'guestbook' and the View 'view" as is.

So it should be

<input type="text" name="signature" value="<%= @signature  %>">