【发布时间】:2019-04-01 09:28:43
【问题描述】:
我想从我的控制器或助手生成一个新链接。所以我不能使用视图中可用的link_to 方法。
我想通过指定控制器和操作来生成路径,而不是使用名称路径。例如:
{action: "index", controller: "accounts", id: "123"}
但是我将上述参数放入什么方法中?我还没有看到Path.new() 方法或类似的方法。
【问题讨论】:
-
您可以在控制器中使用
link_to、*_path或url_for,包括url_helpers:include Rails.application.routes.url_helpers
标签: ruby-on-rails routes ruby-on-rails-5