具有动态段的轨道布线
因此,我刚刚开始使用动态段,因为我需要它们指定某些元素以通过 HTTParty 从 AWS S3 获取数据。
我的routes.rb 文件中有这样的匹配语句:
match ':installation/:venue/:controller(/:action(/:id))'
这非常有效,让我能够准确地完成我想做的事情,即拉入安装和场地,并将它们与HTTParty 一起使用以从S3 获取相应的信息。
现在,我需要像这样保持我的链接持久性,因为我的应用程序控制器会读入这些链接。因此,例如,当我编写 link_to 时,我必须在视图/部分中执行以下操作:
<%= link_to some_name,
"#{@installation}/#{@venue}/#{controller.controller_name}/show/some_id" %>
如果只是这样我必须处理的丑陋不会成为问题,但我不明白如何传递与此相关的选项。
那么基本上有没有办法为动态路段提供资源丰富的路线呢?
So I just started using Dynamic segments as I need them to specify certain elements for grabbing data from AWS S3 via HTTParty.
I have this match statement in my routes.rb file:
match ':installation/:venue/:controller(/:action(/:id))'
This works great and allows me to do exactly what I want to do, which is pull in the installation and venue and use them with HTTParty to get their corresponding information from S3.
Now I need to keep my links through out persistent like these due to the fact that my application controller reads these in. So for example when I write a link_to I have had to do the following in a view/partial:
<%= link_to some_name,
"#{@installation}/#{@venue}/#{controller.controller_name}/show/some_id" %>
If it was just this ugliness I had to deal with that wouldn't be a problem, but I don't understand how I can pass around options in regards to this.
So basically is there a way to have resourceful routes for dynamic segments?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 polimorphic_url
http://apidock.com/rails/ActionDispatch/Routing/PolymorphicRoutes/polymorphic_url
You can use polimorphic_url
http://apidock.com/rails/ActionDispatch/Routing/PolymorphicRoutes/polymorphic_url