简体   繁体   English

我如何找到帮助方法来在Rails视图之外创建html标签

[英]How can I find helper methods to create html tags outside of views in rails

Im creating a seeds file, generating dummy posts with dummy html. 我创建了一个种子文件,使用虚拟HTML生成虚拟帖子。 Im using Faker gem to help with ipsum text but I also want to be able to add html tags (img tags in particular) without the need to hard code. 我使用Faker gem来帮助处理ipsum文本,但我也希望能够添加html标签(尤其是img标签),而无需进行硬编码。 Is there any helpers like those in actionview ie image_tag. 是否有类似actionview中的帮助程序,例如image_tag。

干得好:

ActionController::Base.helpers.image_tag("image.png")

您可以从ActionController :: Base.helpers访问所有帮助器。

ActionController::Base.helpers.image_tag("foo")

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

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