【问题标题】:Rails redirect_to - I also want to the page to reloadRails redirect_to - 我也想重新加载页面
【发布时间】:2017-08-11 03:55:52
【问题描述】:

Turbolinks 在整个应用程序中运行。我需要在特定场景中重新加载页面,在 create 方法中。

这会重定向到正确的页面,但不会重新加载页面:

redirect_to convos_path


这会重定向到 convos_path,但不会重新加载页面

redirect_to convos_path, data: { no_turbolink: true } and return

这没有任何作用

redirect_to convos_path, turbolinks: false and return

我可以在服务器日志中看到它说

Rendered convos/index.html.erb within layouts/application (12.0ms)

我怎样才能做一个redirect_to,并在它到达那里时重新加载页面?

【问题讨论】:

    标签: ruby-on-rails redirect reload


    【解决方案1】:

    Rails Turbolinks 5

    重定向并重新加载整页

    redirect_to @convos_path, turbolinks: false
    

    【讨论】:

      【解决方案2】:

      我从here得到了解决方案。

      <a data-turbolinks='false' href="url_here">Link Here</a>
      

      【讨论】:

        【解决方案3】:

        对我来说,同一问题的解决方案与 turbolink 无关。确保您的表单没有 data-remote="true" 属性。

        form_with,自 Rails 5.1 以来的 recommended 方式,默认创建远程表单,而你 have to pass local: true explicitly

        【讨论】:

          【解决方案4】:

          redirect_back(fallback_location: fallback_location)

          【讨论】:

            猜你喜欢
            • 2013-11-30
            • 2015-02-26
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2015-11-14
            • 1970-01-01
            • 1970-01-01
            • 2018-02-26
            相关资源
            最近更新 更多