为什么在我的上传器中包含 CarrierWave::MiniMagick 会导致我的 APP_PATH 常量被初始化?
why does including CarrierWave::MiniMagick in my uploader cause my APP_PATH constant to be initialized?
我正在从 Paperclip 切换到 CarrierWave,在我的上传器中包含 CarrierWave::MiniMagick 时出现以下错误。
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Exiting
bin/rails:6: warning: already initialized constant APP_PATH
/Users/me/code/project/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
这是我的上传者class:
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process resize_and_pad: [280, 200, :transparent, "Center"]
end
version :medium do
process resize_and_pad: [625, 730, :transparent, "Center"]
end
end
删除包含,我的应用程序可以正常启动。比如,我可以看出 CarrierWave 正在尝试 运行 一个单独的应用程序(我认为?),但我不知道如何配置我的 rails 文件以允许它,并且看不到其他任何人有过类似的问题。帮忙?
已修复。问题是由需要迁移引起的。我之前对 Paperclip 的迁移是作为附件进行的,但 CarrierWave 需要它作为模型上的一列。
我运行 rails g migration AddImageToItems image:string
然后rake db:migrate
.
成功了。还确保删除 Paperclip 的迁移。
我正在从 Paperclip 切换到 CarrierWave,在我的上传器中包含 CarrierWave::MiniMagick 时出现以下错误。
=> Booting WEBrick
=> Rails 4.2.4 application starting in development on http://localhost:3000
=> Run rails server -h for more startup options
=> Ctrl-C to shutdown server
Exiting
bin/rails:6: warning: already initialized constant APP_PATH
/Users/me/code/project/bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]
这是我的上传者class:
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process resize_and_pad: [280, 200, :transparent, "Center"]
end
version :medium do
process resize_and_pad: [625, 730, :transparent, "Center"]
end
end
删除包含,我的应用程序可以正常启动。比如,我可以看出 CarrierWave 正在尝试 运行 一个单独的应用程序(我认为?),但我不知道如何配置我的 rails 文件以允许它,并且看不到其他任何人有过类似的问题。帮忙?
已修复。问题是由需要迁移引起的。我之前对 Paperclip 的迁移是作为附件进行的,但 CarrierWave 需要它作为模型上的一列。
我运行 rails g migration AddImageToItems image:string
然后rake db:migrate
.
成功了。还确保删除 Paperclip 的迁移。