我很难理解为什么使用destroy方法会发生这种情况,因为控制器和路由上的一切都很好!
如果有人通过这种方式请给我一个提示?
路线
resources :users, :as => "" do
resources :sections, :only => [:new, :create, :destroy, :index]
end
控制器
def destroy
@section = Section.find(params[:id])
@section.destroy
redirect_to sections_url
flash[:notice] = "Section deleted"
end
看法
<%= render :partial => "section", :collection => @sections %>
部分的
<%= link_to section.name, section_path(current_user, section) %>
<%= button_to 'Remove', current_user, section, :data => { :confirm => 'Confirm?' }, :class=> "buttom", method: :delete %>