This project is archived and is in readonly mode.

#5465 ✓stale
Bharat Ruparel

Layout in Rails 3.0 Release Candidate 1

Reported by Bharat Ruparel | August 26th, 2010 @ 11:55 AM

I am trying to use a different layout than the default application.html.haml in my Rails 3.0 app. as shown below:

class AdminController < ApplicationController
  layout "admin"
  def instruct
  end
  ...
end

This is my layouts/admin.html.haml file:

 - content_for :secondary_nav do
  = navigation :second_level_admin
= render :file => "layouts/application"

Then I yield to :secondary_nav in my application.html.haml as shown below:

.....
= yield :secondary_nav

My app/views/admin/instruct.html.haml is rendered with no layout!

The same code works fine in Rails 2.3.8

Bharat

Comments and changes to this ticket

  • Bharat Ruparel

    Bharat Ruparel August 30th, 2010 @ 12:39 AM

    The kind of bad coding nested layout problem is causing can be seen at the following URLs:

    http://github.com/bruparel/file_manager238

    http://github.com/bruparel/file_manager3

    Layouts for file_manager238 are elegant. They are ugly for file_manager3. Quite possibly this is a function of my ignorance about Rails 3.0.

    Please take a look and let me know if this is my problem of Rails 3.0 problem.

    Thanks.

    Bharat

  • Neeraj Singh

    Neeraj Singh August 30th, 2010 @ 01:45 AM

    • Importance changed from “” to “Low”

    I find it a bit confusing. If you do not want to use application.html.erb then why refer to it inside your admin layout. can you extract the part out from application.html.erb that you want to use and use that file (with a different name) inside admin layout.

    In short I am suggesting you to try to not to refer to application.html.erb from admin layout.

  • Bharat Ruparel

    Bharat Ruparel August 30th, 2010 @ 02:00 AM

    Neeraj,
    the reason I call application.html.haml is because it creates a nested menu effect. Two layer menu or sub-menu if you will. I have examples running on heroku at URL:

    http://empty-fog-47.heroku.com/

    just login as as admin with userid/password as(system/important) and click on the admin tab. You will see why am I calling application.html.haml
    Bharat

  • Neeraj Singh

    Neeraj Singh August 30th, 2010 @ 10:02 AM

    @Bharart I am sure whatever is the code inside application.html.haml you can extract it out and call it something like foo.html.haml . And then try using foo partial from admin layout.

    Since application.html.haml has special meaning this might solve your problem.

  • Bharat Ruparel

    Bharat Ruparel August 30th, 2010 @ 12:59 PM

    @Neeraj, I already tried it. Didn't work. Maybe I am missing something?
    Bharat

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:32 PM

    • State changed from “new” to “open”

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

  • Santiago Pastorino

    Santiago Pastorino February 2nd, 2011 @ 04:32 PM

    • State changed from “open” to “stale”

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages