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 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
STAFF
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 :)