ruby-on-railspartialcontent-for

rails content_for not showing


I have a :sidebar section in customers/new that I'm yielding to. The content_for section is called from a nested partial. The text "hello1" shows up, but "hello2" does not.

No errors are being thrown and I can't figure out how to troubleshoot.

Any ideas?

**layouts/application.haml**

.container
  - unless signed_in?
   = render "custom/account_#{current_account.id}" rescue nil
  = yield

**customers/new.haml**

= yield :sidebar

**custom/_account_2.haml**

%p hello1
- content_for :sidebar do
 %p hello2

Solution

  • I'm fairly certain that new.haml gets rendered first, and then the partial, and then finally the layout. new.haml getting rendered first is your issue.