我無法找到銷燬記錄的正確方法。我覺得這是一個完整的新手。Rails - 無法弄清楚如何銷燬記錄
這裏是(從rake routes
輸出)有關控制器的路線:
contents GET /admin/contents(.:format) {:controller=>"contents", :action=>"index"}
contents POST /admin/contents(.:format) {:controller=>"contents", :action=>"create"}
new_content GET /admin/contents/new(.:format) {:controller=>"contents", :action=>"new"}
edit_content GET /admin/contents/:id/edit(.:format) {:controller=>"contents", :action=>"edit"}
content GET /admin/contents/:id(.:format) {:controller=>"contents", :action=>"show"}
content PUT /admin/contents/:id(.:format) {:controller=>"contents", :action=>"update"}
content DELETE /admin/contents/:id(.:format) {:controller=>"contents", :action=>"destroy"}
是什麼讓我的底線是不看的比得到任何的不同,並把。
這裏是鏈接:
<%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :delete %>
也試過:
<%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :destroy %>
,輸出是:
<a href="/admin/contents/1400" data-confirm="Are you sure?" data-method="destroy" rel="nofollow">Destroy</a>
有人能發現什麼,我做錯了什麼? : -/
編輯
我沒有intially有rails.js加載。我現在做的。
這裏是我的破壞行動的內容:
def destroy
@content = Content.find(params[:id])
@content.destroy
respond_to do |format|
format.html { redirect_to(contents_url) }
format.xml { head :ok }
end
end
我從內容索引中刪除,就像這樣:
<% @contents.each do |content| %>
<tr>
<td><%= content.name %></td>
<td><%= link_to 'Show', content %></td>
<td><%= link_to 'Edit', edit_content_path(content) %></td>
<td><%= link_to 'Destroy', content, :confirm => 'Are you sure?', :method => :destroy %></td>
</tr>
<% end %>
</table>