Matteo Pagliazzi
Matteo Pagliazzi

Reputation: 5260

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?

Upvotes: 1

Views: 469

Answers (2)

denisjacquemin
denisjacquemin

Reputation: 7414

partials are named with a leading underscore to distinguish them from regular views, even though they are referred to without the underscore.

source: Rails Guides

Upvotes: 2

Ben Lee
Ben Lee

Reputation: 53319

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'

Upvotes: 7

Related Questions