Search code examples
ruby-on-railshamlrenderpartial

Rails impossible to render partials


I'm using the gems "haml" and "haml-rails" in my rails app and I have this folder structure

-views
  -layouts
    -public
      -layout.html.haml
      -_header.html.haml
      -_footer.html.haml

And i wanto to render _header and _footer in layout.html.haml using this code:

= render 'layouts/public/_header'
 .container= yield
= render 'layouts/public/_footer'

but rails raises a MissingTemplate error but _header and _footer exists...

how can i solve?


Solution

  • You typically omit the underscores when specifying partial names in these helpers. Also, you should be passing them in as a :partial parameter:.

    = render :partial => 'layouts/public/header'
     .container= yield
    = render :partial => 'layouts/public/footer'