【发布时间】:2018-09-05 02:17:58
【问题描述】:
我正在尝试在控制器中为嵌套资源创建编辑操作。当我尝试运行编辑操作时,我收到以下错误:
ActiveRecord::RecordNotFound in IngredientsController#edit
Couldn't find Recipe with 'id'=287
下面是我的控制器:
class IngredientsController < ApplicationController
def edit
@recipe = Recipe.find(params[:id])
@ingredient = @recipe.ingredients.find(params[:id])
end
end
还有我的编辑链接:
%= link_to 'Edit Ingredient', edit_recipe_ingredient_path(@recipe, ingredient) %>
任何想法可能导致这种情况?请让我知道是否需要任何其他代码来为问题提供上下文。谢谢!
【问题讨论】:
标签: ruby-on-rails ruby controller nested-resources