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 URL Parameters

Candice Marx
PLUS
Candice Marx
Courses Plus 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].