【问题标题】:why does including CarrierWave::MiniMagick in my uploader cause my APP_PATH constant to be initialized?为什么在我的上传器中包含 CarrierWave::MiniMagick 会导致我的 APP_PATH 常量被初始化?
【发布时间】:2017-06-22 02:42:47
【问题描述】:

我正在从 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 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 文件以允许它,并且看不到其他人有类似的问题。帮忙?

【问题讨论】:

标签: ruby-on-rails imagemagick carrierwave


【解决方案1】:

修复它。问题是由需要迁移引起的。我之前对 Paperclip 的迁移是作为附件进行的,但 CarrierWave 需要它作为模型上的列。

我运行rails g migration AddImageToItems image:string,然后运行rake db:migrate

工作。还要确保删除 Paperclip 的迁移。

【讨论】:

    猜你喜欢
    • 2014-01-24
    • 1970-01-01
    • 1970-01-01
    • 2023-04-11
    • 1970-01-01
    • 1970-01-01
    • 2013-11-04
    • 2014-08-23
    • 1970-01-01
    相关资源
    最近更新 更多