简体   繁体   English

如何在attachment_fu插件的db_files中存储图像?

[英]How to store images in db_files in attachment_fu plugin?

In my rails application I have used attachment_fu plugin for image upload. 在我的Rails应用程序中,我使用了attachment_fu插件来上传图像。

I am new on rails, I want to store file in attachment_fu db_files table. 我是新手,我想将文件存储在attachment_fu db_files表中。

How to store images in db_files and which path i want to specify to display images? 如何将图像存储在db_files中以及我想指定显示图像的路径?

Thanks 谢谢

Unfortunately attachment_fu does not support the same attachment "interface" for :storage => :db_file as it does for :storage => :file_system , but there's a plugin that fills the void here : 不幸的是attachment_fu不支持相同的附件“接口” :storage => :db_file ,因为它确实为:storage => :file_system ,但有在这里填补的空白插件:

https://github.com/kares/attachment_fx https://github.com/kares/attachment_fx

Extends the file interface for the :db_file backend (@see attachment_fu :storage option). 扩展:db_file后端的文件接口(@see附件_fu:storage选项)。 The database backend interface mimics the :file_system storage, the db data is on-demand downloaded into the public directory (the target path prefix is customizable with the :path_prefix option). 数据库后端接口模仿:file_system存储,数据库数据按需下载到公共目录中(目标路径前缀可通过:path_prefix选项自定义)。

You basically use the :file_system methods like You're used to with the :db_file backend eg photo.public_filename(:small) . 基本上,您可以使用:file_system方法,就像您习惯了:db_file后端一样,例如photo.public_filename(:small) As a bonus You can enjoy some useful helpers from the owning model : 作为奖励,您可以从拥有的模型中享受一些有用的帮助:

user.has_photo?
user.photo_path(:small)
user.photo_full_path

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

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