Ruby Building Web Apps with Sinatra ERB Templates URL Parameters

Muhammad sharifi
Muhammad sharifi
4,454 Points

In the get route for the "/greet/:name" path, respond with a string reading "Hello" followed by the contents of the name

can anyone help with this challenge?

hello.rb
require "sinatra"
def page_contenct(name)
  File.read("pages/#{name}.txt")
rescue Errno::ENOENT
  return nil
end

get "/greet/:name" do
   "Hello"
  # YOUR CODE HERE
params[:name]
end

1 Answer

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there, Muhammad sharifi ! You're terribly close. But just like any other string concatenation you're going to need to use a + sign between the "Hello" and the name parameter.

I think you can get it with this hint, but let me know if you're still stuck! :sparkles:

Muhammad sharifi
Muhammad sharifi
4,454 Points

params[:name] + "Hello" didnt work

Jennifer Nordell
Jennifer Nordell
Treehouse Staff

Muhammad sharifi You have the order reversed :smiley: "Hello" + params[:name]