Ruby Practice Sinatra Basics Practice ERB Templates ERB Templates

MaryAnn Eleanya
MaryAnn Eleanya
8,001 Points

I don't know what I am doing wrong

What is wrong with this code?

app.rb
require "sinatra"
require "uri"


get "/:word" do
@word = params[:word]  
erb :word
end
views/word.erb
<h1> <%= @word %> </h1>
<p>  Backwards: <%= @word %></p>
<p>Uppercase: <%= @word %></p>
<p>Length: <%= @word %></p>

1 Answer

Tim Knight
MOD
Tim Knight
Treehouse Moderator 28,749 Points

MaryAnn,

You're really close here. You've got your Sinatra code all correct. What you want to take a look at is your word.erb template code.

Here's what you have right now...

<h1><%= @word %> </h1>
<p>Backwards: <%= @word %></p>
<p>Uppercase: <%= @word %></p>
<p>Length: <%= @word %></p>

Take a look at these objectives for this template:

  • An <h1> heading consisting of the word from the URL parameter
  • A <p> element with the text "Backwards:", followed by the result of calling the reverse method on the word string
  • A <p> element with the text "Uppercase:", followed by the result of calling the upcase method on the word string
  • A <p> element with the text "Length:", followed by the result of calling the length method on the word string

Those final three points should be incorporated into your template. Here's a hint on the first one being added:

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

Now following along with those objectives, just added the uppercase and length items and you'll have it solved.