0

我创建了一个图像上传器并在其中定义了以下版本

version :profile do
  process :resize_and_pad [100, 100]
end

当我上传文件时,我收到以下错误消息:

nil is not a symbol

查看完整的堆栈跟踪,它来自 processing.rb

carrierwave (0.6.1) lib/carrierwave/uploader/processing.rb:85:in `block in process!'
carrierwave (0.6.1) lib/carrierwave/uploader/processing.rb:81:in `each'
carrierwave (0.6.1) lib/carrierwave/uploader/processing.rb:81:in `process!'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `each'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `with_callbacks'
carrierwave (0.6.1) lib/carrierwave/uploader/cache.rb:112:in `cache!'
carrierwave (0.6.1) lib/carrierwave/uploader/versions.rb:230:in `block in cache_versions!'
carrierwave (0.6.1) lib/carrierwave/uploader/versions.rb:216:in `each'
carrierwave (0.6.1) lib/carrierwave/uploader/versions.rb:216:in `cache_versions!'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `each'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `with_callbacks'
carrierwave (0.6.1) lib/carrierwave/uploader/cache.rb:112:in `cache!'
carrierwave (0.6.1) lib/carrierwave/uploader/versions.rb:230:in `block in cache_versions!'
carrierwave (0.6.1) lib/carrierwave/uploader/versions.rb:216:in `each'
carrierwave (0.6.1) lib/carrierwave/uploader/versions.rb:216:in `cache_versions!'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `block in with_callbacks'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `each'
carrierwave (0.6.1) lib/carrierwave/uploader/callbacks.rb:18:in `with_callbacks'
carrierwave (0.6.1) lib/carrierwave/uploader/cache.rb:112:in `cache!'
carrierwave (0.6.1) lib/carrierwave/mount.rb:315:in `cache'
carrierwave (0.6.1) lib/carrierwave/mount.rb:173:in `profile_image='
carrierwave (0.6.1) lib/carrierwave/orm/activerecord.rb:37:in `profile_image='
activerecord (3.2.2) lib/active_record/attribute_assignment.rb:85:in `block in assign_attributes'
activerecord (3.2.2) lib/active_record/attribute_assignment.rb:78:in `each'
activerecord (3.2.2) lib/active_record/attribute_assignment.rb:78:in `assign_attributes'
activerecord (3.2.2) lib/active_record/persistence.rb:212:in `block in update_attributes'
activerecord (3.2.2) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.2.2) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.2) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.2) lib/active_record/persistence.rb:211:in `update_attributes'
app/controllers/users_controller.rb:24:in `update_profile'
4

3 回答 3

1

我认为这是因为缺少论据,请尝试

process :resize_and_pad => [120, 120, "blue", "Center"]

于 2012-05-11T08:45:38.003 回答
1

我不能为重力类型使用简单的字符串,试试这个:

process :resize_and_pad => [100, 100, "white", Magick::CenterGravity]

http://rmagick.rubyforge.org/src_over.html

于 2013-02-04T19:51:25.380 回答
0

您也可以使用十六进制代码,但您需要 octothorp。

process :resize_and_pad => [1000,1000,"#222222", Magick::CenterGravity]
于 2014-12-04T03:03:38.797 回答