0
我有一個配方,成分,Ingredient_Recipe模型rails - 如何顯示在ui中使用多對多關聯模型創建的多對多數據模型?
配方有
成分具有
has_many :ingredient_recipes
has_many :Recipes, :through => :RecipeIngredient
Ingredient_Recipe有
belongs_to :recipes
belongs_to :ingredients
在我的UI
這doenst工作了
<% @recipe.ingredients.each do |ingredient| %>
編輯
ActionView::Template::Error (uninitialized constant Recipe::Ingredients):
97: </td>
98: <tr>
99: <td >
100: <% @recipe.ingredients.each do |ingredient| %>
101: ingredient.name
102: <% end %>
103: </td >
感謝。現在我得到了 - 找不到關聯:RecipeIngredient模型食譜在行<%@ recipe.ingredients.each do |成分| %>(也在調試時,我看到@ associationHAsh =空哈希) – Jeb
對不起,我的錯誤,我會更新答案。 –
做明顯並將其更改爲IngredientRecipe我收到一條無法評估的消息 – Jeb