我不明白为什么我在尝试更新配方时收到上述错误消息
这是我的佣金路线输出
recipes GET /recipes(.:format) recipes#index
POST /recipes(.:format) recipes#create
new_recipe GET /recipes/new(.:format) recipes#new
edit_recipe GET /recipes/:id/edit(.:format) recipes#edit
recipe GET /recipes/:id(.:format) recipes#show
PUT /recipes/:id(.:format) recipes#update
DELETE /recipes/:id(.:format) recipes#destroy
root / public_pages#index
我的控制器看起来像这样
def edit
@recipe = Recipe.find(params[:id])
end
def update
@recipe = Recipe.find(params[:id])
if @recipe.update_attributes(params[:recipe])
redirect_to recipes_path, :notice => "Successfully updated recipe"
else
render :action => 'edit'
end
end
我编辑帖子的链接
<%= link_to "Edit Recipe", edit_recipe_path(@recipe) %>
完整错误是(这是在尝试访问食谱页面时
)Routing Error
No route matches {:action=>"edit", :controller=>"recipes"}
Try running rake routes for more information on available routes.
最后我正在使用的表单,现在我唯一可以想到的是我的表单有问题,虽然我认为你可以使用相同的表单进行新的编辑?虽然我可能完全错了
任何人都有任何想法
答案 0 :(得分:2)
<%= link_to "Edit Recipe", edit_recipe_path(r.id) %>
这是因为我正在传递
<% @recipes.each do |r| %>