Skip to content

Instantly share code, notes, and snippets.

@alexch
Created May 10, 2012 18:00
Show Gist options
  • Save alexch/2654771 to your computer and use it in GitHub Desktop.
Save alexch/2654771 to your computer and use it in GitHub Desktop.
important parts of chapter 4 of railstutorial
# Listing 4.3. The sample application site layout.
# app/views/layouts/application.html.erb
<title><%= full_title(yield(:title)) %></title>
# Listing 4.2. Defining a full_title helper.
# app/helpers/application_helper.rb
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title)
base_title = "Ruby on Rails Tutorial Sample App"
if page_title.empty?
base_title
else
"#{base_title} | #{page_title}"
end
end
end
# Listing 4.4. Updated tests for the Home page’s title.
# spec/requests/static_pages_spec.rb
(see book)
# Listing 4.5. The Home page with no custom page title.
# app/views/static_pages/home.html.erb
<h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment