新手问题 关于 bootstrap-will_paginate 分页

wwwicbd · April 05, 2016 · Last by wwwicbd replied at April 06, 2016 · 2039 hits

用的bootstrap-will_paginate来做的分页, 在第二页(page 为‘2’)删除一个用户, 操作之后如果还想重定向到第二页,有什么好办法来传递 page 参数吗?

正如#1 楼所说,Rails 中几乎所有 xxx_path,都可以传参数的,比如这样:xxx_path(a: 111)

#2 楼 @qinfanpeng

多谢指点,我后来改成这个样子就可以了。(发现 params 其实是个方法!)

视图里:

<% if current_user.admin? && !current_user?(user) %>
    | <%= link_to "删除账户",
                  user_path(user,page:params[:page]),
                  method: :delete,
                  data: {confirm: "高危操作!"} %>

控制器里:

redirect_to users_url(page:params[:page])
You need to Sign in before reply, if you don't have an account, please Sign up first.