Rails 3 的删除方法不能用了 delete put

update:
先试试
#production.rb
config.serve_static_assets = true


有view
<%= link_to "Delete", admin_question_path(question), :confirm => "Are you sure?", :method=>:delete %>

#生成如下

<a href="/admin/questions/3" data-method="delete" rel="nofollow">Delete</a>


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?" %>


<form method="post" action="/admin/questions/244"  class="button_to">
  <div>
    <input name="_method" type="hidden" value="delete" />
    <input class="destroy" data-confirm="Are you sure?" type="submit" value="Delete" />
    <input name="authenticity_token" type="hidden" value="yApLSCAIIqDBeubxR7RflOo+BnDByQHgSJzhtKvIATM=" />
  </div>
</form>


http://piotrsarnacki.com/2010/09/14/mountable-engines/

你可能感兴趣的:(JavaScript,jquery,REST,Ruby,Rails)