Rails - 带参数的成员操作 - 路径助手?
我看到这篇关于向成员操作路由添加参数的文章:
当我手动输入完整的 URL 时,路由效果很好:www.whatever.com/resource/:resource_id/action/:action_parameter
有没有方便的路径助手我可以在我的观点中使用链接到此吗?例如,如果它只是一个没有参数的普通成员操作,我可以使用
action_resource_path(:resource_id)
是否有与额外参数等效的操作?
I saw this post about adding parameters to a member action route:
Rails3 Routes - Passing parameter to a member route
And the routing works great when I enter the full URL manually: www.whatever.com/resource/:resource_id/action/:action_parameter
Is there a convenient path helper I can use to link to this in my views? For example, if it is just an ordinary member action WITHOUT a parameter, I can use
action_resource_path(:resource_id)
Is there an equivalent with the extra parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
as
选项指定 url 帮助器:生成的路由将如下所示:
您可以像这样使用它:
You can specify a url helper with the
as
option:The route that gets generated will look like:
You can use that like: