具有动态段的轨道布线

发布于 2025-01-08 02:34:25 字数 547 浏览 1 评论 0原文

因此,我刚刚开始使用动态段,因为我需要它们指定某些元素以通过 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文