[英]Rails : Passing Variable to new controller method from view
I just want to knwo if it's possible to pass a variable to a 'new' controller method when using a helper. 我只是想知道是否可以在使用辅助程序时将变量传递给“新”控制器方法。
I thought it was something like that : 我以为是这样的:
link_to "New", new_controller_path, method: :get, var: var
With a hash params like this params[... var: var]. 使用像这样的哈希参数params [... var:var]。
Best regards. 最好的祝福。
是的,只需确保将参数作为URL的一部分:
link_to "Create User", new_controller_path(email: "hi@email.com", password: "secret")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.