Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8958603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:15:06+00:00 2026-06-15T15:15:06+00:00

In Michael Hartl’s RoR tutorial: the exercises at the end of chapter 5 involve

  • 0

In Michael Hartl’s RoR tutorial: the exercises at the end of chapter 5 involve simplifying RSpec tests.

5.37 ( http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec-layout_exercises ) defines several test for the home page.
In the file spec/helpers/application_helper_spec.rb:

require 'spec_helper'

describe ApplicationHelper do

  describe "full_title" do
  .
  .
  .
  .
    it "should not include a bar for the home page" do
      full_title("").should_not =~ /\|/
    end
  end
end

For this test to pass, I need to have the Home page title display:
“Ruby on Rails Tutorial Sample App”
And not “Ruby on Rails Tutorial Sample App | Home”

But, the tutorial doesn’t walk me through how to code that change.

Here’s what I’ve tried:

In app/views/static_pages/home.html.erb:

  1. Remove:

    <% provide(:title, 'Home') %>

In app/views/layouts/application.html.erb
Edit the tag to:

<title>
 <% if :title
  full_title = "Ruby on Rails Tutorial Sample App | " && yield(:title)
 else
  full_title = "Ruby on Rails Tutorial Sample App"
 end %>
 <%= print full_title %>
</title>

And other variations my noob brain could muster.
Here’s what I’m trying to accomplish:

If the page has no title provided, return “Ruby on Rails Tutorial Sample App”

If there is a title provided, return “Ruby on Rails Tutorial Sample App | #PageTitle”

Any suggestions are appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:15:08+00:00Added an answer on June 15, 2026 at 3:15 pm

    What about this?

    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
    

    http://ruby.railstutorial.org/chapters/rails-flavored-ruby#code-title_helper

    Just call the method inside your view.
    So it should be something like
    <title><%= full_title(yield(:title)) %></title>
    as he says.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm going through the tutorial on http://ruby.railstutorial.org/ by Michael Hartl. I'm on chapter six
I'm trying to follow Michael Hartl's Ruby on Rails Tutorial in http://ruby.railstutorial.org/chapters/sign-in-sign-out , but
Im doing Michael Hartl's excellent tutorial series on ruby on rails here: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and
I am working through Michael Hartl's Ruby on Rails Tutorial Chapter 5 exercises and
I'm working through Michael Hartl's Ruby on Rails tutorial on http://ruby.railstutorial.org . I'm having
I'm following Ruby on Rails Tutorial: Learn Rails by Example, by Michael Hartl. http://ruby.railstutorial.org/chapters/a-demo-app#sec:a_micropost_microtour
I am following Michael Hartl's Rails Tutorial Here: http://ruby.railstutorial.org/chapters/modeling-and-viewing-users-one#top I use this command to
I'm looking at some RSpec code in Chapter 6 of Michael Hartl's [Rail Tutorial]:
In Michael Hartl's Ruby on Rails Tutorial, ch 7.2.3 , rspec is returns the
i m following michael hartl's ruby on rails online tutorial book and finished chapter

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.