简体   繁体   English

我可以在条件条件下使用有条件的编辑路径在Rails link_to上使用Ruby吗?

[英]Can I use an edit path with conditional for ruby on rails link_to?

I wan to create a link_to tag with a conditional for example: 我想用条件创建一个link_to标记,例如:

The below code probably doesn't work... do not try 下面的代码可能不起作用...请不要尝试

link_to "Edit postal address", edit_postal_address_path( :condition => {:organization_id => @organization_id } )

I want to edit the postal address with the organization_id that I have in a variable. 我想用变量中的organization_id编辑邮政地址。 Is there a slick way of doing this or would I have to take the long way? 有这样做的巧妙方法还是我必须走很长的路?

I hope this makes sense. 我希望这是有道理的。

link_to "Edit postal address", edit_postal_address_path( PostalAddress.where("organization_id = ?", @organization_id)

此关系应该是每个组织的has_one邮寄地址

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM