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 Practice Sinatra Basics Practice ERB Templates ERB Templates

MaryAnn Eleanya
MaryAnn Eleanya
8,626 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
Tim Knight
28,888 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.