我不明白为什么在尝试更新食谱时收到上述错误消息
这是我的 rake 路线输出
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.
最后是我正在使用的表单,现在我唯一能想到的是我的表单存在问题,尽管我认为您可以使用相同的表单进行新建和编辑?虽然我可能完全错了
有人有想法么