- Respond to HTTP Requests with Rails Routes and Controller Actions.
- Render ERB from a Rails Controller Action.
This lesson practices creating ERB views and rendering them from a Rails Controller
Action in response to an HTTP request. Fork and clone this repository and run
bundle install
to get started!
The Rails application is already set up with the necessary routes and controller actions. The view templates exist in the app/views/application
directory but need to be completed with the requested content.
Run rails server
to start a local server so that you can test your app in your
browser. Once your application is running, assuming port 3000, the Rails
default, you should be able to hit the following local urls:
http://localhost:3000/hello, http://localhost:3000/goodbye,
http://localhost:3000/date, and http://localhost:3000/ (root).
You can run bundle exec rspec
to get the tests passing and see errors.
The following routes are already configured in config/routes.rb
:
- GET
/hello
→ApplicationController#hello
- GET
/goodbye
→ApplicationController#goodbye
- GET
/date
→ApplicationController#date
- GET
/
(root) →ApplicationController#index
Complete the following view templates:
-
Complete the template
hello.html.erb
inapp/views/application
so that it contains anh1
tag with the contentHello World
. This template is already configured to be rendered via the GET/hello
route by yourApplicationController
inapp/controllers/application_controller.rb
. -
Complete the template
goodbye.html.erb
inapp/views/application
. In this view, use ERB tags to create a variablename
. This variable should store the nameJoe
. Then, using ERB tags, say "Goodbye Joe" in anh1
tag. This template is already configured to be rendered via the GET/goodbye
route by yourApplicationController
. -
Complete the template
date.html.erb
inapp/views/application
that gets rendered via GET/date
. It should contain anh1
with the contentToday
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 Wednesday, November 18, 2015
.