Sinatra Views Lab


  1. Respond to HTTP Requests with Sinatra Routes.
  2. Render ERB from a Sinatra Action.


This lesson practices creating ERB views and rendering them from a Sinatra Action in response to an HTTP request. Fork and clone this repository and run bundle install to get started!


For each of the following examples, create a .erb file in the views directory and a route in app.rb which renders that template. Make sure each template contains the requested content.

Run shotgun to start a local server so that you can test your app in your browser. Once your application is running, assuming port 9393, the shotgun default, you should be able to hit the following local urls: http://localhost:9393/hello, http://localhost:9393/goodbye, and http://localhost:9393/date.

You can run learn test to get the tests passing and see errors.

  1. Create a template called hello.erb in views that contains an h1 tag with the content Hello World. This should get rendered via a GET /hello route by your App controller in app.rb.

  2. Create another template called goodbye.erb in views. In this view, use ERB tags to create a variable name. This variable should store the name Joe. Then, using ERB tags, say "Goodbye Joe" in an h1 tag. This should get rendered via a GET /goodbye route by your App controller in app.rb.

  3. Create a template called date.erb in views that gets rendered via GET /date. It should contain an h1 with the content Today

Using ERB tags, and the DateTime library, display today's date in a p tag. The date should be formatted to look something like this The date is Friday, August 06, 2021.

Note: The date must match this format exactly, including the 06 for the date if it's in the first nine days of the month. Check out the spec file to see how to get this format if you're stuck!

Unlock your future in tech
Learn to code.

Learn about Flatiron School's Mission

With a new take on education that falls somewhere between self-taught prodigy and four-year computer science degree, the Flatiron School promises to turn students with little programming experience into developers.

In the six months since the Manhattan coding school was acquired by WeWork, it has spawned locations in Washington, D.C., Brooklyn, and London. Now, WeWork is opening a fourth Flatiron School location, this time in Houston.

Adam Enbar, Flatiron School's cofounder, believes now is the time to grow. "How the world is changing has impacted working and learning in very similar ways. We think education fundamentally is about one thing: enabling people to pursue a better life."

Learn. Love. Code.
Students come to Flatiron School to change their lives. Join our driven community of career-changers and master the skills you need to become a software engineer or a data scientist.
Find Us