Rails 菜单

发布于 2024-07-14 06:57:01 字数 80 浏览 4 评论 0原文

我想知道是否有一个好的插件可以在 Rails 中渲染导航链接。 如果它可以直接从路由文件渲染控制器上所有可能的 GET 操作的链接,那就太好了。

I would like to know if there is a good plugin for rendering navigation links in Rails. It would be nice if it could render links to all possible GET actions on a controller directly from the routes file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

稍尽春風 2024-07-21 06:57:01

我可以问你问题的目的吗? RESTful 控制器中只有四个获取操作(索引、显示、编辑和新建)。 使用特殊的路由生成器动态生成列表的开销可能太大了。

您可以简单地创建一个部分,可以为您当前正在查看的任何控制器呈现这四个操作(想想 params[:controller])。

就所有可能的获取操作而言:所有可能的获取操作都将包含数据库中每个项目的显示操作。 也就是说,最好在部分和使用 link_to 中进行处理。

但很难给出完整的答案,因为您的情况似乎很独特。

我希望这能有所帮助。

-克里斯

Can I ask the purpose of your question? There are only four get actions in a RESTful controller, (index, show, edit, and new). The overhead in producing a list using a special route generator on the fly is probably too much.

You could simply create a partial that can render those four actions for whatever controller you're currently viewing (think params[:controller]).

As far as for all possible Get actions: All possible get actions would encompass the show action for each item in your database. That is, again, best handled in a partial and the use of link_to.

It's hard to give a complete answer though, because your circumstances seem unique.

I hope this helps even a little.

-Chris

深空失忆 2024-07-21 06:57:01

虽然这不能回答这个具体问题,但您可以通过运行在命令行上查看您

rake routes

自己的所有路线这将为您提供站点上所有路线的个人读数,但是就像克里斯上面所说的那样,这不是确实是一个具体的答案,更多的是仅供参考。

干杯!

While this does not answer ths specific question, you can see all of your OWN routes on the command line by running

rake routes

This will give you your own personal readout of all of your routes on the site, however like Chris said above, this isn't really a specific answer, more of an FYI.

Cheers!

記柔刀 2024-07-21 06:57:01

你应该尝试 Mmmenu: http://github.com/snitko/mmmenu
它非常灵活。

You should try Mmmenu: http://github.com/snitko/mmmenu
It's very flexible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文