nginx CarrierWave::Crop::ProcessingError(无法裁剪-:en不是有效的区域设置)

dw1jzc5e  于 2023-10-17  发布在  Nginx
关注(0)|答案(1)|浏览(152)

我正在做一个rails项目,我有一个产品模型,里面有一个上传图片的字段。我正在使用carrierwave gem进行上传,项目在运行nginx的服务器上。
我需要上传的项目内的路径public/uploads的图片。在开发环境中一切正常,但在生产中,当我上传图片时,网站崩溃。
我已经用tails /var/log/nginx/error.log命令检查了服务器上的生产日志,但由于某种原因,它只显示了POST/PATCH操作之前的情况。
这是我的product模型:

class Product < ApplicationRecord
  mount_uploader :picture, PictureUploader

end

这是我的picture uploader文件:

class PictureUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick

  process crop: [400, 400]

  # Choose what kind of storage to use for this uploader:
  storage :file

  # Override the directory where uploaded files will be stored.
  # This is a sensible default for uploaders that are meant to be mounted:
  def store_dir
    'uploads'
  end

  def extension_whitelist
    %w(jpeg jpg png)
  end

  def content_type_whitelist
    /image\//
  end

  # Override the filename of the uploaded files:
  # Avoid using model.id or version_name here, see uploader/store.rb for details.
  def filename
    "#{secure_token}.#{file.extension}" if original_filename.present?
  end

  protected
  def secure_token
    var = :"@#{mounted_as}_secure_token"
    model.instance_variable_get(var) || model.instance_variable_set(var, SecureRandom.uuid)
  end

end

这是我为网站配置的nginx配置:

server {
    listen 8081;
    server_name 127.0.0.1;

    # Tell Nginx and Passenger where your app's 'public' directory is
    root /var/www/project/current/public;

    # Turn on Passenger
    passenger_enabled on;
    passenger_ruby /home/deploy/.rbenv/versions/2.4.1/bin/ruby;
}

*谢谢你提前:)
编辑

我找错地方了。生产日志为/var/www/project/current/log
这是我得到的错误:

D, [2017-07-04T16:50:19.330282 #1341] DEBUG -- : [c7b9956c-786f-440c-bc38-e13718f3493e]    (0.1ms)  BEGIN
D, [2017-07-04T16:50:19.331113 #1341] DEBUG -- : [c7b9956c-786f-440c-bc38-e13718f3493e]    (0.2ms)  ROLLBACK
I, [2017-07-04T16:50:19.331277 #1341]  INFO -- : [c7b9956c-786f-440c-bc38-e13718f3493e] Completed 500 Internal Server Error in 4ms (ActiveRecord: 0.7ms)
F, [2017-07-04T16:50:19.331669 #1341] FATAL -- : [c7b9956c-786f-440c-bc38-e13718f3493e]   
F, [2017-07-04T16:50:19.331691 #1341] FATAL -- : [c7b9956c-786f-440c-bc38-e13718f3493e] CarrierWave::Crop::ProcessingError (Failed to crop - :en is not a valid locale):
F, [2017-07-04T16:50:19.331704 #1341] FATAL -- : [c7b9956c-786f-440c-bc38-e13718f3493e]   
F, [2017-07-04T16:50:19.331716 #1341] FATAL -- : [c7b9956c-786f-440c-bc38-e13718f3493e] app/controllers/products_controller.rb:39:in `block in update'
[c7b9956c-786f-440c-bc38-e13718f3493e] app/controllers/products_controller.rb:38:in `update'

显然,这是一个问题的区域设置文件。我还使用carrierwave-crop-on-fly gem在上传时裁剪图像,这似乎是错误的一部分。
我的申请表上有这个。

config.i18n.default_locale = :es
config.i18n.available_locales = :es
config.i18n.enforce_available_locales = true

如果我找到答案我会更新问题

zpgglvta

zpgglvta1#

在添加en.yml文件并将其包含在区域设置中之后,下一个错误是:translation missing: en.errors.messages.mini_magick_processing_error
结果发现服务器上没有安装Imagemagick
要解决这个问题,你需要运行:sudo apt-get install imagemagick在远程服务器上。

感谢kenneth亲自回答了这个问题。

相关问题