Seen from the outside, this chapter hardly accomplished anything: we started with static pages, and ended with… mostly static pages. But appearances are deceiving: by developing in terms of Rails controllers, actions, and views, we are now in a position to add arbitrary amounts of dynamic content to our site. Seeing exactly how this plays out is the task for the rest of this tutorial.
Before moving on, let’s take a minute to commit the changes on our topic branch and merge them into the master branch. Back in Section 3.2 we created a Git branch for the development of static pages. If you haven’t been making commits as we’ve been moving along, first make a commit indicating that we’ve reached a stopping point:
$ git add -A $ git commit -m "Finish static pages"
Then merge the changes back into the master branch using the same technique as in Section 1.4.4:17
$ git checkout master $ git merge static-pages
Once you reach a stopping point like this, it’s usually a good idea to push your code up to a remote repository (which, if you followed the steps in Section 1.4.3, will be Bitbucket):
$ git push
I also recommend deploying the application to Heroku:
$ rails test $ git push heroku
Here we’ve taken care to run the test suite before deploying, which is a good habit to develop.
3.5.1 What We Learned in This Chapter
For a third time, we went through the full procedure of creating a new Rails application from scratch, installing the necessary gems, pushing it up to a remote repository, and deploying it to production.
The rails script generates a new controller with rails generate controller ControllerName <optional action names>.
New routes are defined in the file config/routes.rb.
Rails views can contain static HTML or embedded Ruby (ERb).
Automated testing allows us to write test suites that drive the development of new features, allow for confident refactoring, and catch regressions.
Test-driven development uses a “Red, Green, Refactor” cycle.
Rails layouts allow the use of a common template for pages in our application, thereby eliminating duplication.