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

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  %>">