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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:15:51+00:00 2026-05-28T03:15:51+00:00

My application has some static content: root :to => ‘pages#home’ match ‘/about’, :to =>

  • 0

My application has some static content:

root :to => 'pages#home'
match '/about',   :to => 'pages#about'
match '/contact', :to => 'pages#contact'
match '/help',    :to => 'pages#help'

I want these pages to share a layout rather than duplicate the header / footer in each file.

The only documentation around layouts I have found seems to indicate that I should specify my layouts at the controller level, is that correct?

If so, how should give my static pages layouts? The only workaround I see is to create a bunch of empty controllers for each page, for the sole purpose of specifying a common layout file, but that smells like overkill.

Am I missing a trick?

Thanks for any help

  • 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-28T03:15:51+00:00Added an answer on May 28, 2026 at 3:15 am

    Yes, set the layout at the controller level. You could create a controller for this group of pages like this:

    class AboutController < ApplicationController
        layout "about"
    
        def about
        end
    
        def contact
        end
    
        def help
        end
    end
    

    I tend to use the name “AboutController” for this sort of thing, to avoid confusion with truly static files that don’t pass through a controller at all. But you could name it whatever you like.

    Point your routes at it (e.g. about#contact). Then create the layout in app/views/layouts/about.html.erb

    If you ever need to change the layout for a particular action, you can use the render method’s :layout option:

    def something_special
        render :layout => "other"
    end
    

    You can also pass false if you don’t want a layout at all, like for robots.txt.

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

Sidebar

Related Questions

I'm trying to create an iFrame application with some static content and a comment
My heroku website's root page is essentially static, it has some ruby code in
I believe the application has some parts that target .NET, and some that don't.
Is there a good application (that has some kind of gui) for testing memory
I have a 3yr old application that has some controllers with some very unrestful
I have built a Java application that has some dependencies (~10). I would like
I am working on an application which has got some sensitive information. I am
My iPhone application has several views and some viewControllers for that views. I need
I have a Spring application that I believe has some bottlenecks, so I'd like
I have a web application on ASP.NET (C#) that has some precompiled components. I've

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.