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 348467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:22:02+00:00 2026-05-12T11:22:02+00:00

Working on my first Rails project, I used Ryan Bates’ Nifty-Generators to create the

  • 0

Working on my first Rails project, I used Ryan Bates’ Nifty-Generators to create the initial application files. This gives me a LayoutHelper with a title method:

def title(page_title, show_title = true)
  @content_for_title = page_title.to_s
  @show_title = show_title
end

In my homepage view, I have a simple title:

<%= title "Welcome" -%>

And finally, in my layout (application.html.erb), I have:

<%- if show_title? -%>
  <h1><%=h yield(:title) %></h1>
<%- end -%>

<%= yield %>

What I’m seeing is my title, “Welcome”, followed by the value passed (or defaulted to) for show_title. I want the former, but not the latter. I understand why the boolean is being implicitly returned by the method, but I didn’t expect it to be displayed. The boolean display seems to be appearing as part of the primary content yield.

The yield command still hasn’t really clicked for me yet (I get it, I just don’t get it, if that makes sense), so I’m hoping someone can help me understand why the boolean is being printed and how I can make it stop. That answer may help me better understand how yield works in addition to solving the immediate problem.

Thanks.

  • 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-05-12T11:22:02+00:00Added an answer on May 12, 2026 at 11:22 am

    Try this:

    <% title "Welcome" %>
    

    You want to call the title method, not write out its return value when you call it.

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

Sidebar

Related Questions

I am very new to ruby on rails.. working on my first project... am
I'm working on my first real-world Rails project. So far, I'm mostly mashing up
I'm doing my first Ruby on Rails project. I am working on a project
I'm working on my first 'real' (as opposed to playing around) rails 3 project
I'm working on deploying my first Rails application right now, and somewhere along the
I'm working on my first Ruby on Rails aplication and it's quite big (at
I have pretty much finished my first working Symbian application, but in my hastened
I'm working on my first Django application. In short, what it needs to do
I am currently working on my first asp.net mvc application. I am trying to
I'm new to iPhone and Apple development and working on my first application. It

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.