Reputation: 6217
The following view is calling a partial and declaring locals for it in a way that is consistent with the Rails guides:
<% @wines_for_winetype.each_with_index do |wine, index| %>
<%= render 'price_table', locals: {wine: wine} %>
But this is generating an error
undefined local variable or method 'wine' for #<#:0x00007fba1fb97298> Did you mean? @wine @wines
Yet in the dev mode with the live shell the following:
demonstrates that the locals exist.
Why are they not being handled in the view partial according to expected syntax? how should this me fixed?
Upvotes: 2
Views: 80
Reputation: 106
@mrzasa is right. If you want to omit the partial
keyword, then you need to omit the locals
keyword too.
<%= render 'price_table', wine: wine %>
Upvotes: 2
Reputation: 23347
You missed the partial
keyword:
<% @wines_for_winetype.each_with_index do |wine, index| %>
<%= render partial: 'price_table', locals: {wine: wine} %>
Upvotes: 4