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 Adding New Data Submitting the Form Via POST Request

Andrew Ackerman
Andrew Ackerman
8,347 Points

Struggling with task 3.

I'm not entirely sure how to ask this, but I'm very confused as to what I'm doing wrong, am I over thinking this?

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

<form method="post" action="/signatures/create">
  <input type="text" name="signature">
  <input type="submit">
</form>
guestbook.rb
require "sinatra"

# Appends the signature to the file as a new line.
def save_signature(signature)
  File.open("signatures.txt", "a") do |file|
    file.puts signature
  end
end


get "/signatures/new" do
  erb :new
end



post "/signatures/create" do
    save_signature(params["text"], params["signature"])
  redirect URI.escape"/#{params["text"]}"
end
Andrew Ackerman
Andrew Ackerman
8,347 Points

The task is "Within the post "/signatures/create" route block, call the save_signature method. save_signature takes a signature string as an argument, so pass it the value of the signature form field."

I'd really appreciate any help! Thanks!

2 Answers

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

save_signature takes one argument, but you're passing two. Reduce it to one (and make sure it's the correct one, because only one of the two parameters you're accessing is valid), and Task 3 should pass.

Andrew Ackerman
Andrew Ackerman
8,347 Points

Thank you so much for that!