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 trialSol Caceres
2,432 PointsHaving trouble assigning the value of a method to an instance variable- Task 2 of 4- Building apps with Sinatra
Not sure what I'm doing wrong with this one. Can't seem to figure out how to assign the value of the load_signature() method to my @signature instance variable.
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
# YOUR CODE HERE
load_signature(@index)
@signature = load_signature()
@index = (params["index"])
end
<p>Please enter your name below.</p>
<form>
<input type="text" name="signature" value="<%= %>">
<input type="submit">
</form>
2 Answers
Oğulcan Girginc
24,848 PointsThe problem is in lines 13 and 14:
load_signature(@index)
@signature = load_signature()
On line 14, your method needs an object as a parameter, but you forgot to write it.
If you just want the right answer, let me know! :)
Sol Caceres
2,432 PointsGot it. Thanks!
load_signature(@index)
@signature = load_signature(@index)
Oğulcan Girginc
24,848 PointsYep, that's perfect! ??