控制器似乎运行顺畅:
Pict Create (0.8ms) INSERT INTO "picts" ("usercontent_id", "image", "caption", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["usercontent_id", 94], ["image", "croc1.jpg"], ["caption", "emotional rescue"], ["user_id", 11], ["created_at", "2019-05-13 20:11:03.353852"], ["updated_at", "2019-05-13 20:11:03.353852"]]
↳ app/controllers/picts_controller.rb:36
(0.6ms) ROLLBACK
但回滚save
命令(下面的第三行)
@pict = Pict.new(pict_params)
authorize @pict
@pict.save
我删除了所有验证(尽管在rails 5.2中,belongs_to被强制执行-我仍然通过设置optional: true
进行了测试),包括一个文件大小验证器...并且结果始终相同。 >
坦率地说,除了@pict
之外,我什至无法想象nil的含义,但是它为所有属性都具有适当的参数,并通过了Pundit策略进行访问控制。
因此,我假设载波引擎存在某些错误。 carrierwave-aws
也已安装且相同
CarrierWave.configure do |config|
设置用作现有的功能应用程序。该模型声明
mount_uploader :image, ImageUploader
依次是:
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :aws
参数确实显示了将图像文件放置在临时箱中。
{"utf8"=>"✓",
"authenticity_token"=>"/ZY1FmOBBlVUdfayK3w7ws+4JgrbLt7U9gjvdyniOIqPMfvB10TUYEgvlDyyTTN9SCOu2zbYdb39Ydd37XdXvg==",
"pict"=>
{"nazione_id"=>"15",
"image"=>
#<ActionDispatch::Http::UploadedFile:0x00007f72d76516b0
@content_type="image/jpeg",
@headers="Content-Disposition: form-data; name=\"pict[image]\"; filename=\"croc1.jpg\"\r\n" + "Content-Type: image/jpeg\r\n",
@original_filename="croc1.jpg",
@tempfile=#<File:/tmp/RackMultipart20190513-9509-f934ua.jpg>>,
"caption"=>"emotional rescue",
"regione_id"=>""},
"usercontent_point"=>"Mitchell street darwin",
"commit"=>" Add ",
"locale"=>"en"}
是什么导致undefined method 'match' for nil:NilClass
错误?
更新
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:82:in `block in partition_matching_region'
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:81:in `each'
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:81:in `find'
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:81:in `partition_matching_region'
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:70:in `get_partition'
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:23:in `signing_region'
aws-partitions (1.151.0) lib/aws-partitions/endpoint_provider.rb:99:in `signing_region'
aws-sdk-s3 (1.36.1) lib/aws-sdk-s3/plugins/s3_signer.rb:20:in `block in <class:S3Signer>'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:70:in `call'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:213:in `block in resolve_defaults'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:57:in `each'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:57:in `each'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:212:in `resolve_defaults'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:205:in `value_at'
aws-sdk-core (3.48.4) lib/seahorse/client/configuration.rb:189:in `block in resolve'
答案 0 :(得分:0)
undefined method 'match' for nil:NilClass
表示该方法试图在空的东西上运行。
正如一个评论所建议的,这可能是一个错误的配置。
另一个假设是没有任何可比的。缺少整个配置块。该文件可能位于错误的目录中或不存在。
这种特殊情况下,开发服务器的deploy.rb
配置错误,而没有符号链接到实质文件