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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:57:25+00:00 2026-05-18T19:57:25+00:00

Essentially what I want to do is have a root application.haml that contains the

  • 0

Essentially what I want to do is have a root application.haml that contains the core css and js then the site layout goes something like

  • application.haml
    • marketing.haml(s) with their own css’s and markups
    • userbackend.haml(s) with their own css’s and markups
    • siteadministrators.haml(s) with their own css’s and markups

So I tried doing this by adding a sub_layout to my controllers so for instance my home controller which is a marketing sections gets:

def sub_layout
    "marketing"
  end

controllers for the actualy application that the users use

def sub_layout
   "userapplication"
end

def sub_layout
   "siteadministrators"
end

then in the application.haml I call
= render(:parital => “layouts/#{controller.sub_layout}”)

this returns “undefined method `formats’ for nil:NilClass”

Like many on here I’m very new to rails and haml especially though I do have experience with .NET MVC and the Spark View engine

any thoughts on what this haml looks like?

  • 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-18T19:57:26+00:00Added an answer on May 18, 2026 at 7:57 pm

    As you suspected, there is a standard and much, much better way of doing this.
    Your application.haml:

    !!! XML
    !!!
    %html
      %head
        %title Title
        = stylesheet_link_tag 'global'
        = yield :styles
      %body
        #content
          = yield
        = yield :scripts
    

    And then your marketing.haml:

    - content_for :styles do
      = stylesheet_link_tag 'marketing'
    
    - content_for :scripts do
      = javascript_include_tag 'marketing'
    
    %h1 It's Marketing time!
    

    Anything in the ‘content_for :styles’ block gets executed in the context of it’s respective yield in the layout. You don’t need to have a content_for for every yield, if you have multiple, the results get concatenated.

    Enjoy!

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

Sidebar

Related Questions

Essentially what I want to do is have a root application.haml that contains the
I have 3 date range forms on my site. Essentially I want to hide
I want to implement a view in an iPhone application that is essentially like
I've gotten myself into a situation that seems fairly unusual, and essentially want to
Essentially what I want to do is to apply additional CSS classes to individual
For example, I have 3 counters (which I essentially want to represent as truth
Essentially I want to have my blog grab wall photos, status updates, etc. from
I have a basic question about MPI programming in C. Essentially what I want
I have data that I want to pull from a mySQL database and I
I have set of files (which are essentially .exe files) that I allow the

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.