在另一个文件夹中显示rails中的图像

时间:2022-01-06 00:23:35

How could I display an image from a folder other than images folder under the app/assets? Suppose I have another folder called im under assests. i.e app/assets/im and I need to display an image under the im folder with the name same as an image under the images folder, how could I do it?

如何在app / assets下的images文件夹以外的文件夹中显示图像?假设我有另一个名为im的文件夹。即app / assets / im我需要在im文件夹下显示一个图像,其名称与images文件夹下的图像相同,我该怎么办呢?

1 个解决方案

#1


0  

If you are using Asset Pipeline, all folders (not in the pre-compilation path) will be copied to the public/assets folder.

如果使用Asset Pipeline,则所有文件夹(不在预编译路径中)都将复制到public / assets文件夹。

To access the asset, simply do asset_url("im/image_name.png"). This will fetch your image.

要访问资产,只需执行asset_url(“im / image_name.png”)。这将获取您的图像。

#1


0  

If you are using Asset Pipeline, all folders (not in the pre-compilation path) will be copied to the public/assets folder.

如果使用Asset Pipeline,则所有文件夹(不在预编译路径中)都将复制到public / assets文件夹。

To access the asset, simply do asset_url("im/image_name.png"). This will fetch your image.

要访问资产,只需执行asset_url(“im / image_name.png”)。这将获取您的图像。