Ruby Building Web Apps with Sinatra ERB Templates URL Parameters

Candice Marx
PRO
Candice Marx
Pro Student 2,879 Points

page_content(params[:name]). Isn't that how to display the content?

I've tried solving this, with the code below. I don't understand why it's not accepting my answer. I submitted a string, and then they way to show the URL content within the parameter name.

hello.rb
require "sinatra"

get "/greet/:name" do
  "Hello"
  page_content(params [:name])
end

1 Answer

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

The page_content method only exists as part of the wiki app that we're building in the videos. This challenge is for a completely separate and much simpler "app" that consists entirely of the code in the hello.rb file.

All you need to do is return a string from the get "/greet/:name" block. So if params[:name] contained "Candice", you'd need to return the string "Hello Candice".

Note that params needs to be followed immediately by square brackets in order to work. In your sample you have params [:name] (with a space); you'll need to change that to params[:name].