早上好,
我遇到了嵌套评论的问题。我有一个显示这些的部分,但我想在 .each 的底部添加一个删除片段。
以下是部分内容:
_snippets.html.erb
<% @snippets.each do |snippet| %>
<%= raw(snippet.content) %>
<% if can? :manage, snippet %>
<%= link_to 'delete', book_snippet_path(snippet), :method => :delete %>
<% end %>
<% end %>
这是我的路线:
book_snippets POST /books/:book_id/snippets(.:format) snippets#create
edit_book_snippet GET /books/:book_id/snippets/:id/edit(.:format) snippets#edit
book_snippet PATCH /books/:book_id/snippets/:id(.:format) snippets#update
PUT /books/:book_id/snippets/:id(.:format) snippets#update
DELETE /books/:book_id/snippets/:id(.:format) snippets#destroy
这是堆栈错误,显示没有路由匹配更新?
No route matches {:action=>"update", :controller=>"snippets", :id=>nil, :book_id=>#<Snippet id: 4, content: "<p>YACHT!</p>\r\n", book_id: 4, created_at: "2013-11-15 09:12:20", updated_at: "2013-11-15 09:12:25", approved: true, user_id: 1>, :format=>nil} missing required keys: [:id]
我知道这可能是我错过的一些愚蠢的事情,但真的很想得到一些帮助来解决这个问题。
谢谢 :)