This has been asked many times, but after trying all the solutions that I can find, I'm no closer towards a solution of my own.
I have a partial, _form
- here's the relevant part:
<% @tournament.sub_tournaments.each do |sub| %>
<%= f.fields_for :sub_tournaments, sub, :validate => false do |sub_form| %>
...
<table>
...
<tbody>
<%= sub_form.fields_for :standings, :validate => false do |standings| %>
<%= render 'tournaments/form_partials/standing_fields', f: standings, sub: sub %> #here's the problem
<% end %>
</tbody>
</table>
...
<% end %>
<% end %>
In the marked line, I'm attempting to pass two variables to the given partial - f: standings
and sub: sub
. If I pass only f: standings
, the page loads fine, but when I add sub: sub
, I get the following error:
undefined local variable or method `sub'
which is referencing the following marked line in the _standing_fields
partial:
<tr>
<td><%= f.hidden_field :_destroy %><%= f.text_field :standing, :class => "standing", readonly: true, :type => "" %></td>
<% if Game::TEAM_GAMES.include? sub.game.name %> #here's the problem
<td><%= f.grouped_collection_select(:team_division_id, Team.order(:name).includes(:team_divisions), :team_divisions, :name, :id, :game_name, include_blank: true)%></td>
<% else %>
<td><%= f.grouped_collection_select(:player_id, Player.order(:name).includes(:player), :player, :name, :id, :game_name, include_blank: true)%></td>
<% end %>
<td><span class="remove">Remove</span></td>
</tr>
I can't think of what's going wrong, I've triple checked the syntax, spelling, commas, etc as well as restarting my redis server and the rails server as one solution suggested.