销毁后如何从参数中删除id?

How to delete id from params after destroy?

我通过 RailsCast 制作了可排序的列 #228 可排序的 Table 列 一切顺利。 但是当我通过 ajax 添加销毁记录时,排序 links 在删除

后不起作用

application_helper.rb

#application_helper.rb
def sortable(column, title = nil)
 title ||= column.titleize
 css_class = (column == sort_column) ? "current #{sort_direction}" : nil
 direction = (column == sort_column && sort_direction == "asc") ? "desc" : "asc"
 link_to title,  params.merge(:sort => column, :direction => direction, page: nil),  {:class => css_class, remote: true }
 end

contracts_controller.rb

#contracts_controller.rb
def destroy
 @contract.destroy
 if params[:limit]
  @contracts = Contract.includes(:department).order(sort_column + ' ' + sort_direction).page(params[:page]).per(params[:limit])
 else
  @contracts = Contract.includes(:department).order(sort_column + ' ' + sort_direction).page(params[:page])
 end
 respond_to do |format|
  format.html {}
  format.js {flash.now[:danger] = "Success delete"}
 end
end

删除link

<%= link_to 'Delete', contract, remote: true, method: :delete, data: { confirm: 'Are you sure?' } , class: 'btn btn-danger'%>

销毁link后排序是/contracts/1?direction=asc&sort=contractor,但我需要/contracts?direction=asc&sort=contractor

sortable helper link 可能需要这样改变,

link_to title,  your_index_path(params.merge(:sort => column, :direction => direction, page: nil)