【问题标题】:How do you add a query string into link_to when using array notation?使用数组表示法时,如何将查询字符串添加到 link_to 中?
【发布时间】:2013-11-18 12:53:43
【问题描述】:

link_to 允许您使用数组指定嵌套对象路径:

= link_to(page.title, [page.magazine, page])

我不知道如何将查询字符串添加到这种格式中。有可能吗?

【问题讨论】:

    标签: ruby-on-rails routing


    【解决方案1】:

    不。您传递的数组有效,因为它被解释为隐式多态路径,并传递给polymorphic_url。结果是使用路由表找到的,并且没有任何内置支持使用这种格式的附加参数。如果您需要额外的参数,请使用另一种 url-helper 格式。

    【讨论】:

      猜你喜欢
      • 2011-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-20
      相关资源
      最近更新 更多