Dragonfly将文件保存在(环境)目录下,例如:
public/system/dragonfly/development/
或
public/system/dragonfly/production/
是否可以制作公共目录并保存所有( dragonfly )以进行生产和开发?
public/system/dragonfly/
答案 0 :(得分:0)
我希望这能帮助那些有这样疑问的人:
您应该在初始化文件config / intializers / dragonfly.rb中使用root_path更正该行
root_path: Rails.root.join('public/system/dragonfly', Rails.env)
并删除路径中没有变量的Rails.env。
#config/intializers/dragonfly.rb
require 'dragonfly'
# Configure
Dragonfly.app.configure do
plugin :imagemagick
secret "e83b8affbf1c807c7788c07d27e70e79fb0459f8e2c4375b59e60a3da11631e5"
url_format "/media/:job/:name"
datastore :file,
root_path: Rails.root.join('public/system/dragonfly', Rails.env),
server_root: Rails.root.join('public')
end
# Logger
Dragonfly.logger = Rails.logger
# Mount as middleware
Rails.application.middleware.use Dragonfly::Middleware
# Add model functionality
if defined?(ActiveRecord::Base)
ActiveRecord::Base.extend Dragonfly::Model
ActiveRecord::Base.extend Dragonfly::Model::Validations
end