Im creating a many to many association rails project, and im getting the following errors when i run new.html.erb:
Table 'purchase_form_rails.account_numbers_pi_names' doesn't exist
undefined local variable or method `account_numbers' for #<#<Class:0x2a979ef4>:0x2a978770>
Extracted source (around line #34):
(It should be looking in the database purchase_form_rails, and the table account_numbers (the in between table joining pi_names and account_numbers is pi_names_account_numbers)
Heres my new.html.erb:
<div class="field">
<% for account_number in @account_numbers %>
<input type="checkbox"
id="<%=account_number.id%>"
name="account_numbers_ids[]"
value="<%=account_number.id %>"
<%if @pi_name.account_numbers.include? tag%>checked="checked"<%end%>
> <%=account_numbers.account_number%>
<% end %>
</div>
Let me know if you need any more info!
If you are defining a has_many:thorough then rails expects join table name should be alphabetically sorted like account_numbers_pi_names( This should be the join table name not pi_names_account_numbers) .