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

Muhammad sharifi
Muhammad sharifi
4,455 Points

anyone know why this is not working.?

i have set The form's "action" attribute to "/signatures/create"

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

<form method="post" action="signature/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

# ADD CODE TO RECEIVE FORM SUBMISSIONS 
post "/signatures/create" do 
  save_signature (params["signature"])
  redirect "/#{params["signature/create"]}"
end

1 Answer

Clayton Perszyk
MOD
Clayton Perszyk
Treehouse Moderator 48,850 Points

your action is set to "signature/create" , not "/signatures/create". You are missing an 's' and a '/'.