gpt4 book ai didi

ruby-on-rails - 多态 url_for 的 URL 参数

转载 作者:太空宇宙 更新时间:2023-11-03 17:57:08 27 4
gpt4 key购买 nike

我目前有这段代码:

link_to 'add a new baz!', new_foo_bar_baz_path(@foo, @bar, baz: { thing: 'the-value' })

生成此 url:

http://ganxy.local/foos/1/bars/2/bazes/new?baz%5Bthing%5D=the-value

Because of some changes I'm making to my app I want to make the url generation polymorphic. So, something like this:

link_to 'add a new baz!', [@foo, @bar, :baz]# : { thing: 'the-value' })

有没有办法将 ?baz%5Bthing%5D=the-value 添加到末尾,还是我需要手动生成字符串?

最佳答案

我不建议使用多态 url,因为它比辅助方法慢 2 倍。查看my post about this

关于ruby-on-rails - 多态 url_for 的 URL 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11514489/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com