RAILS:回形针和基于创建日期的目录结构
有谁知道我如何配置我的rails模型,该模型使用回形针进行数据存储,以使用基于创建日期的目录,例如在fleximage中?
目前我正在使用:
has_attached_file :bookblock, :path => "#{CONF['storage_path']}bookblock/:id_partition/:style.:content_type_ehas_attached_filextension"
但我需要的是这样一个
has_attached_file :bookblock, :path => "# {CONF['storage_path']}bookblock/:created_at_year/:created_at_month/:created_at_day/:c:id_partition/:style.:content_type_ehas_attached_filextension"
简单的:目录路径中的created_at也会
{CONF['storage_path']}/:created_at/bookblock/:id_partition/:style.:content_type_ehas_attached_filextension"
提前帮助Thanx,
Alex
does anyone know how I can configure my rails model, which is using paperclip for data storage, to use creation date based directories like for example in fleximage ??
At present I'm using:
has_attached_file :bookblock, :path => "#{CONF['storage_path']}bookblock/:id_partition/:style.:content_type_ehas_attached_filextension"
but what I need is something like this
has_attached_file :bookblock, :path => "# {CONF['storage_path']}bookblock/:created_at_year/:created_at_month/:created_at_day/:c:id_partition/:style.:content_type_ehas_attached_filextension"
a simple :created_at in the directory path would also help
{CONF['storage_path']}/:created_at/bookblock/:id_partition/:style.:content_type_ehas_attached_filextension"
Thanx in advance,
Alex
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以将自己的插值添加到回形针。举一个简单的例子:
现在您可以在
:path
选项中使用:year
,如下所示:您可以定义三个插值:
:year
,:month
和:day
,或者仅返回整个年/月/日字符串。You can add your own interpolations to Paperclip. To give a simple example:
Now you can use
:year
in the:path
option like this:You could define three interpolations:
:year
,:month
and:day
, or just one that returns the whole year/month/day string.