Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Ruby Building Web Apps with Sinatra ERB Templates Embedding Instance Variables

alexx1000
alexx1000
16,187 Points

In hello.rb, in the get route for the "/greet/:name" path, set the @name instance variable to equal the contents of the

Sorry, I'm new here and don't know how to use the different features. I'm confused about what code I should put in this challenge. I hope you can see the question and my ugly code lol Can you please help me? Thanks!! :)

hello.rb
require "sinatra"

get "/greet/:name" do
  @name = params[:name]
  erb :views
end
views/hello.erb
<p><%= @name = "Hello" %></p>

2 Answers

AJ Tran
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
AJ Tran
Treehouse Teacher

ERB is a funny beast, it looks like you got one answer!

This will work the same too:

<p>Hello <%= @name %></p>
alexx1000
alexx1000
16,187 Points

Got the right answer: <p><%= "Hello" + @name %></p>

LOL :)