So I have a recipes app that I'm working on and I can't understand why I'm not getting something to display. I'm using Recipe as a join table and for simplicity I only included it along with three other tables. For purposes of the app the only thing I'm wanting to display is the name associated on each model.
I have the following models: Vegetable Protein Starch Recipe
Recipe is acting as the join table and has:
belongs_to :vegetable
belongs_to :protein
belongs_to :starch
accepts_nested_attributes_for :vegetable, :protein, :starch
Each of the other model has:
has_one :recipe
So my thought for the view was a simple iteration
<table>
<thead>
<tr>
<th> Vegetable Name </th>
<th> Protein Name </th>
</tr>
</thead>
<% @recipes.each do |recipes| %>
<tr>
<td> <%= recipe.vegetable.name %> <td>
<td> <%= recipe.protein.name %> <td>
</tr>
Yet nothing is coming up beyond the headers. I've done various things with the iteration like changing recipes to recipe, passing recipe as an argument at the end of each column. I've made sure that my Recipe controller has the following:
def recipe_params
params.require(:recipe).permit(:vegetable_id, :protein_id, :starch_id)
end
Am I wrong in my associations and that's why it's not presenting anything?