Ruby Practice Sinatra Basics Practice ERB Templates ERB Templates

Paige Jones
Paige Jones
16,192 Points

anyone able to finish this challenge? completed the rest but i stumped here.

Ive finished the sinatra course and was able to complete the other challenges but this one has me feeling lost.

app.rb

views/word.erb

2 Answers

yk7
yk7
Full Stack JavaScript Techdegree Student 18,918 Points

Hello Paige, sorry for the Delayed replay;

you see your code here is perfect:

h1><%= @word %></h1> 
<p>Backwards: <%= @word.reverse %>
</p> <p>Uppercase: <%= @word.upcase %></p> 
<p>Length: <%= @word.length %></p>

the issue is in the APP.erb file. nice Job it was just a small bobo,

require 'sinatra'
get "/:word" do
 @word = params[:word] 
*** :****
end

ok, so the ***** is a missing line in your code to point(redirect) to the HTML template.

the link if you need refresh; https://teamtreehouse.com/library/getting-html-from-a-template

yk7
yk7
Full Stack JavaScript Techdegree Student 18,918 Points

Hello! the challenge consists of two part;

1.from the URL you have to save to a variable whatever word after the "/" : you can just this video: https://teamtreehouse.com/library/url-parameters start from 2nd min!

2.the instance variable that you just created you will use it in the word.erb. and manipulated as it s required by using the method mentioned in the challenge: .reverse .upcase .length

Hope that Helps ! :)

Paige Jones
Paige Jones
16,192 Points

Hi Youssef thanks for helping - I am getting closer! I am still getting an error "The response for /dog doesn't seem to include an h1 element with the text "dog".

this is what i currently have:

<h1><%= @word %></h1> <p>Backwards: <%= @word.reverse %></p> <p>Uppercase: <%= @word.upcase %></p> <p>Length: <%= @word.length %></p>

in APP.erb:

require 'sinatra'

get "/:word" do @word = params[:word] end

thank you!