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 trialRhonda Goolsby
6,992 Pointsredirect
Why doesn't this work?: redirect("/#params{['signatures/new']}")
<p>Please enter your name below.</p>
<form method="post" action="/signatures/create">
<input type="text" name="signature">
<input type="submit">
</form>
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["signature"])
redirect("/#params{['signatures/new']}")
end
# ADD CODE TO RECEIVE FORM SUBMISSIONS HERE
1 Answer
kyle strachan
2,206 Pointspost "/signatures/create" do
save_signature(params[:signature])
redirect("/signatures/new")
end
Your new.erb is correct, what isn't correct however is how you're referencing the signature an how you're trying to redirect.
To get the signaturre from the form it must be params[:signature], To redirect you need to reference the path which means like the post do "/signatures/create" but instead of create its new so "/signature/new", if you have any questions please let me know :)