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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:59:43+00:00 2026-05-30T12:59:43+00:00

Is it possible to manipulate the placeholders so that I can not only set

  • 0

Is it possible to manipulate the placeholders so that I can not only set their content, but also add/remove content in a particular order? For example:

layouts/base.html.erb (a base layout meant to be extended):

<!DOCTYPE html>
<html>
    <head>
    <title><%= yield :title %></title>
    <%= yield :stylesheets %>
    <%= yield :javascripts %>
    <%= yield :csrf %>
    </head>
    <body>

    <div class='container-fluid'>
      <%= yield :header %>

      <%= content_for?(:content) ? yield(:content) : yield %>

      <%= yield :footer %>
    </div>
    </body>
</html>

layouts/application.html.erb (this is the layout I will be using for the most part of my app, it inherits from the base layout):

<% content_for :stylesheets do %>
  <%= stylesheet_link_tag    "application", :media => "all" %>
<% end %>

<% content_for :javascripts do %>
  <%= javascript_include_tag "application" %>
<% end %>

<% content_for :csrf do %>
  <%= csrf_meta_tags %>
<% end %>

<%= render :template => 'layouts/base' %>

Now I want a layout for a specific controller, which may need to add more javascript links, or maybe completely remove them. Let’s say I want to add only one file after the other javascripts. So far I got this:

layouts/some_controller.html.erb (this is a layout for a particular controller, it should inherit from the application layout):

<% content_for :javascripts do %>
  <script src="/assets/some_javascript_that_depends_on_jquery.js" type="text/javascript"></script>
<% end %>

<%= render :template => 'layouts/application' %>

This won’t work, because it will place some_javascript_that_depends_on_jquery.js at the beginning of the :javascripts placeholder, and I need it at the end because it depends on jquery.

It would suck to have to extend the base layout directly, and keep track of any change made to the application layout to apply it to the controller-specific layout too.

What would be the recommended way to deal with this situation?

  • 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-30T12:59:45+00:00Added an answer on May 30, 2026 at 12:59 pm

    This can’t be done as in other frameworks where you just extend layouts and then modify the inherited blocks at will.

    Rails sort of forces you to keep it simple.

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

Sidebar

Related Questions

Is manipulate Silverlight in automated-tests possible? If yes - How can I do that?
Is it possible to set root permissions for php script and manipulate with system
I tried to manipulate the __mro__ but it it read-only The use case is
Is it possible to manipulate the ampersand in sed? I want to add +1
Is it possible to adjust manipulate option, so that this formula is written in
Is it possible to use Mathematica's manipulate to change variables that have already been
Is it possible to manipulate the components, such as year , month , day
Is it possible to use the Open XML sdk to manipulate parts of document
Using iTextSharp (and c#/ASP.NET) is it possible to open an RTF document, manipulate it
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should

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.