根据文档:
redirect_back(fallback_location:,allow_other_host:true,**args)
:fallback_location- 将用于丢失Referer标头的默认后备位置。
:allow_other_host- 允许或禁止重定向到与当前主机不同的主机,默认为 true。
可以传递给 redirect_to 的所有其他选项都被接受为选项并且行为是相同的。
并redirect_to允许我通过将它们作为哈希传递来将参数添加到 url
那么,为什么这些都不适合我:
redirect_back fallback_location: tasks_path, allow_other_host: false, syncing: trueredirect_back fallback_location: tasks_path, allow_other_host: false, { syncing: true }redirect_back fallback_location: tasks_path, allow_other_host: false, options: { syncing: true }redirect_back(fallback_location: tasks_path, allow_other_host: false, options: { syncing: true })redirect_back(fallback_location: tasks_path, allow_other_host: false, syncing: true)...以及我能想到的上述任何其他迭代。
所有这些(都是有效的代码),只需返回我而不添加参数
我正在尝试实现此 URL:
(back_url or fallback_location) + '?syncing=true'
如果您查看源代码,redirect_back您会发现它本质上使用redirect_to "whatever_url.com"了redirect_to方法的版本。
如果您查看redirect_to 的解释,您会发现在这个用例中,您很遗憾无法传递任何参数。如果这是非常需要的,我想您可以覆盖redirect_back方法以使用字符串连接将 params 选项附加到 url ,但这似乎是一个令人讨厌的修复。
但是要回答您的问题 - 您想要实现的目标似乎是开箱即用的。
| 归档时间: |
|
| 查看次数: |
2243 次 |
| 最近记录: |