[英]rails 3 destroy action fails
销毁动作:
def destroy
@tag = Tag.find(params[:id])
@tag.destroy
respond_to do |format|
format.html { redirect_to(tags_url) }
format.xml { head :ok }
end
end
链接:
<a href="/tags/14" data-confirm="Are you sure?" data-method="delete" rel="nofollow">Destroy</a>
单击它可显示显示动作。
Started GET "/tags/14" for 127.0.0.1 at Wed Oct 27 18:36:41 -0500 2010
Processing by TagsController#show as HTML
Parameters: {"id"=>"14"}
Tag Load (0.2ms) SELECT "tags".* FROM "tags" WHERE ("tags"."id" = 14) LIMIT 1
Rendered tags/show.html.erb within layouts/application (8.5ms)
Completed 200 OK in 25ms (Views: 12.1ms | ActiveRecord: 0.2ms)
javascript_include_tag:默认值包含在我的页面中,并且脚本标记可以正确呈现。 Firebug没有给我任何错误。 在Firefox和Opera中都会发生这种情况。
这可能是您编写link_to方法的方式。
<%= link_to "Destroy", tag, :method => :delete, :confirm => "Really?" %>
试试看
确保在您的routes.rb文件中声明了资源,因为这就是此freebee url的来源。
在2.3.8中
map.resources :tags
在R3中,我真的不知道,但是指南中有这样的内容
resources :tags
要使用方法覆盖,您需要发送_method
参数。 对于像destroy这样的操作,它应该是您将_method
参数设置为delete
POST表单,如果您愿意,可以在单击链接时在JS中构造该表单。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.