Day 10: Working Through Chapter 4 of the Ruby on Rails Tutorial

I will be going back and typing up my reviewing of Chapter 2 and 3, but I want to get in the habit of reviewing the content on here. It really helped me to solidify what I was learning. I definitely suggest it to others!

So, Chapter 4 is titled Rails-flavored Ruby. Mr. hartl explains that, “This chapter is designed to give you a solid foundation in Rails-flavored Ruby, whether or not you have prior experience in the language.” I will be working on it tonight and tomorrow morning, so it will be split up on here. I want to absorb it, not just breeze through and not get it. Here we go!

The chapter starts out looking at the application.html.erb file in views/layouts. In particular, the focus is on this line:

The “stylesheet_link_tag” is a Rails function that works to include “application.css” for all media types. The first goal in this chapter is going to be to create a “helper” to allow for the base title, “Ruby on Rails Tutorial Sample App” to appear on the home page without the leading pipe symbol, the |. Not sure why we hate the | but down with the |.

To do this, we will be creating a helper called “full_title” that will return only the base title. The helper will be created in “app/helpers/application_helper.rb” and will look like this:

And then, we go to “app/views/layouts/application.html.erb” and switch this line:


and then go to “test/controllers/static_pages_controller_test.rb” and change the test for the Home page to say:

and go to the “app/views/static_pages/home.html.erb” file and remove the line:

Then, we run the Guard exec and see that we only have no failures.

Well, that is it for today. I had another long day of work and I am beat. I will be continuing in the morning, plus I plan to drop in to the Saturday Coding at CodeNewbie on Slack tomorrow. See details here. My goal for tomorrow is to complete Chapter 4 and maybe to do my review of Chapter 2. I am not sure yet if I should continue to do the reviews as thoroughly as I am or to push on quicker through the material. Any thoughts?