Ruby on Rails:向控制器添加第二个自定义视图 (Rails 3)
Rails 3:
我对 Rails 还很陌生,到目前为止一切都进展顺利,但我在理解所有这些路由内容时遇到了一些困难。 我现在尝试向控制器添加第二个视图,但我不想使用任何显示、编辑、索引等操作。
我想要视图的自定义名称和控制器中的自定义操作。有人可以向我解释一下如何做到这一点吗? 而且我真的很想知道如何使用“link_to”方法从另一个视图链接到它。
非常感谢任何帮助!
Rails 3:
I'm pretty new to rails and so far it's all gone really well but I'm having a little trouble understanding all of this routing stuff.
I'm now trying to add a second view to my controller but I don't want to use any of the show, edit, index, etc. actions.
I want to a custom name for the view and a custom action in the controller. Could someone please explain to me how to do this.
And also I would really like to know how to link to it from another view using the "link_to" method.
Any help is greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经常使用休息并创建自定义操作和视图,我只使用路由,
因此我创建了 3 个用于资源收集的操作和 1 个用于资源的操作,
您可以从控制台运行
rake paths
并查看路由列表,有为带有后缀 _path 的每个路由预定义帮助程序。文档中的示例I often use rest and for creating custom actions and views I just use routes
so I created 3 actions for collection of resource and 1 for resource
you can run
rake routes
from console and see list of routes, there are predefined helpers for every route with postfix _path. example from documentation