Search code examples
ruby-on-railsrubymodels

Ruby on Rails does not display the right Partial


In my patient show view i have a part that refers to a partial

<h2>Anamnesen</h2>
<%= render @patient.anamneses %>

So i also created an partial in views/anamneses/ called _anamnese.html.erb

<p>
<b>Beschreibung:</b>
<%= anamnese.beschreibung %>
</p>

Now, my problem is that only Beschreibung: can be seen, the <%= anamnese.beschreibung %> is somehow blank! So maybe someones gues what i made wrong!


Solution

  • You need to pass variables explicitly by locals option for the partials to know it.

    In the first template

    render partial: 'anamneses/anamneses', locals: {anamneses: @patient.anamneses}