gpt4 book ai didi

ruby-on-rails - 缺少必需的选项 :name

转载 作者:行者123 更新时间:2023-12-03 23:15:51 25 4
gpt4 key购买 nike

我正在尝试设置 AWS 和carrierwave 从我的网站上传图片。但是,当我尝试上传/更新帖子时,我不断收到错误消息“缺少必需的选项:名称”。我按照教程设置了我的 S3 帐户并设置了carrierwave.rb。如果您有任何想法,请告诉我!

载波

CarrierWave.configure do |config|
config.storage = :aws
config.aws_bucket = ENV['S3_BUCKET_NAME']
config.aws_acl = 'public-read'
config.aws_authenticated_url_expiration = 60 * 60 * 24 * 7
config.aws_attributes = {
expires: 1.week.from_now.httpdate,
cache_control: 'max-age=604800'
}

config.aws_credentials = {
access_key_id: ENV['AWS_ACCESS_KEY_ID'],
secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
region: ENV['AWS_REGION']
}
end

.env 示例
S3_BUCKET_NAME=*****
AWS_ACCESS_KEY_ID=*****
AWS_SECRET_ACCESS_KEY=*****
AWS_REGION=*****

投资组合_上传者.rb
class PortfolioUploader < CarrierWave::Uploader::Base

storage :aws

def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

def extension_white_list
%w(jpg jpeg gif png)
end
end

最佳答案

我也遇到了这个问题。错误消息具有欺骗性。我发现它实际上是config.aws_bucket = ENV['S3_BUCKET_NAME']导致问题的行。如 config.aws_bucketnil (比如当ENV['S3_BUCKET_NAME']未设置时,你会在控制台中得到欺骗性的missing required option :name

关于ruby-on-rails - 缺少必需的选项 :name,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50912795/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com