Note that there are some explanatory texts on larger screens.

plurals
  1. POM Hartl's Ruby on Rails Tutorial Chapter 5 custom title on home page
    primarykey
    data
    text
    <p>In Michael Hartl's RoR tutorial: the exercises at the end of chapter 5 involve simplifying RSpec tests. </p> <p>5.37 ( <a href="http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec-layout_exercises" rel="nofollow">http://ruby.railstutorial.org/chapters/filling-in-the-layout#sec-layout_exercises</a> ) defines several test for the home page. In the file spec/helpers/application_helper_spec.rb:</p> <pre><code>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 </code></pre> <p>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"</p> <p>But, the tutorial doesn't walk me through how to code that change.</p> <p>Here's what I've tried:</p> <p>In app/views/static_pages/home.html.erb:</p> <ol> <li><p>Remove:</p> <p><code>&lt;% provide(:title, 'Home') %&gt;</code></p></li> </ol> <p>In app/views/layouts/application.html.erb Edit the tag to:</p> <pre><code>&lt;title&gt; &lt;% if :title full_title = "Ruby on Rails Tutorial Sample App | " &amp;&amp; yield(:title) else full_title = "Ruby on Rails Tutorial Sample App" end %&gt; &lt;%= print full_title %&gt; &lt;/title&gt; </code></pre> <p>And other variations my noob brain could muster. Here's what I'm trying to accomplish:</p> <p>If the page has no title provided, return "Ruby on Rails Tutorial Sample App"</p> <p>If there is a title provided, return "Ruby on Rails Tutorial Sample App | #PageTitle"</p> <p>Any suggestions are appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload