在refinerycms中更改上传文件的本地存储位置

时间:2012-03-28 14:41:59

标签: ruby-on-rails-3 refinerycms dragonfly-gem

我正在使用refinerycms 1.0.9,我想更改dragonfly保存文件的默认位置。

这是我在config / initializers中的dragonfly.rb:

require 'dragonfly'

app = Dragonfly[:app_name]
app.datastore = Dragonfly::DataStorage::FileDataStore.new

app.datastore.configure do |d|
  d.root_path = '/Projects/images'
  d.server_root = '/Projects'
  d.store_meta = false
end

当我保存文件时,我收到以下错误:

Dragonfly::Shell::CommandFailed (Command failed (identify '/var/folders/5t/mf86p8gx6bz94dzfb88xpvpr0000gn/T/RackMultipart20120328-6943-1vbpa7u') with exit status 127):

更新

我重新安装了imagemagick并且摆脱了错误,但它仍然将文件保存到/ system / images。我尝试在炼油厂中覆盖Image模型并添加:

image_accessor :image do
   storage_path{ "/Projects/images/#{rand(100)}" }
end

但这也不起作用。

1 个答案:

答案 0 :(得分:0)

基于作者的this post,您似乎希望在模型中设置storage_path选项:

storage_path{ "some/path/#{first_name}/#{rand(100)}" } # or whatever you want it to be