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

  • SEARCH
  • Home
  • 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 4622714
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:52:57+00:00 2026-05-22T02:52:57+00:00

I am following this tutorial http://guides.rubyonrails.org/layouts_and_rendering.html and trying to separate the header div from

  • 0

I am following this tutorial http://guides.rubyonrails.org/layouts_and_rendering.html and trying to separate the header div from the rest of the HTML templates.

I have taken out a div from my app/views/home/index.html.erb file and replaced it with

<%= yield :head %>

Then I made a file called head.html.erb in the /app/views/layouts directory and put that div in there. Then I put this code around the div:

<% content_for :head do %>
<% end %>

But it doesn’t work and the header div does not get displayed. Where did I go wrong? I think there is a path and directory mismatch, but I am not sure exactly how to match them up.

Thank you!

  • 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-22T02:52:58+00:00Added an answer on May 22, 2026 at 2:52 am

    Your layout is where you put the yield call, and each view’s template is where you put the content_for block. You’ll probably want your yield call in your application’s main layout file.

    So in app/views/layouts/application.html.erb put this where you want it to be:

    <div id="my_header_div">
      <%= yield :head %>
    </div>
    

    Then in each view, you can do this:

    <% content_for :head do %>
      <h1>My Header!</h1>
    <% end %>
    

    And it will insert inside the div in your layout file.

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

Sidebar

Related Questions

I am following this routing tutorial for Ruby on Rails: http://guides.rubyonrails.org/routing.html It says that
I'm following the tutorial here: http://guides.rubyonrails.org/getting_started.html Everything was working fine until I tried 8.1
I have been learning RESTful webservices following this tutorial http://www.vogella.de/articles/REST/article.html . As I understand,
I am following this guide for python 2.7 : http://docs.python.org/tutorial/interpreter.html I do all it
First attempt at a RoR project and following http://guides.rubyonrails.org/getting_started.html#creating-the-blog-application . I've got the Welcome
Following this tutorial http://netbeans.org/kb/docs/javaee/maven-osgiservice-cdi.html I have managed to create a simple OSGI bundle and
http://www.codinghorror.com/blog/2008/04/setting-up-subversion-on-windows.html I am following this as a guide to install subversion. The tutorial at
Following this tutorial: http://www.vogella.de/articles/AndroidServices/article.html#receiver I created my own project. Manifest: <?xml version=1.0 encoding=utf-8?> <manifest
I am following this tutorial: http://www.generation5.org/content/2001/sr00.asp?Print=1 Right off the bat it asks me to
I am following this tutorial: http://www.9lessons.info/2011/03/live-table-edit-with-jquery-and-ajax.html My addition is most content is ajax/json/dynamic. I

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.