Rails 3 的删除方法不能用了 delete put
发布日期:2021-09-29 20:08:59 浏览次数:18 分类:技术文章

本文共 1064 字,大约阅读时间需要 3 分钟。

update:
先试试
#production.rb config.serve_static_assets = true
有view
<%= link_to "Delete", admin_question_path(question), :confirm => "Are you sure?", :method=>:delete %>
#生成如下 Delete
http://localhost:3000/admin/questions/4/edit #而不是 http://localhost:3000/admin/questions/4/destroy
#routes.rb Questionator::Application.routes.draw do |map|   root :to => "admin/dashboard#show"   namespace "admin" do     root :to => "admin/dashboard#show"     resources :questions   end end rake routes admin_question DELETE /admin/questions/:id(.:format)      {:action=>"destroy", :controller=>"admin/questions"}
所以不是路由的问题,
然后,看到说换button_to 因为Rails 3用的javascript转换的rest对应的方法,如果,你的javascript加载和jquery加载冲突就会有问题
<%= csrf_meta_tag %> <%= javascript_include_tag :defaults %> <%= javascript_include_tag 'jquery-1.4.2.min','jquery.form','rails.js'%>
<%= button_to "Delete", admin_question_path(@question.id), :method=>:delete, :class=>:destroy,:confirm=>"Are you sure?" %> 
[url]http://piotrsarnacki.com/2010/09/14/mountable-engines/[/url]

转载地址:https://blog.csdn.net/horace_lee/article/details/83945258 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:rails render partial 参数 变量说明
下一篇:有关ruby load path

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年03月21日 22时59分20秒