I get error in partial line #1: undefined local variable or method 'level'
Code in my view:
<div id="comments">
<% level = 0%>
<% @comments.each do |comment| %>
<%=render partial: 'comments/single_comment', locals: {level: level, comment: comment} %>
<% end %>
<% if 0 < level %>
<% (level).times do %>
</div>
<% end %>
<% end %>
</div>
</div>
And partial first lines:
<% if comment.level < level %>
<% (level - comment.level).times do %>
</div>
<% end %>
<% end %>
Any idea what's wrong here?
@commentand@levelmaybecommentvariable in partial works,leveldoesn't. Is this because I set it before the block?Commenthas a column calledlevel?comment.levelproblem butlevelvariable.comment.levelin your view. I believe the problem is not related to the variable...