- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
每当我尝试启动服务器时,我都会收到此错误 validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
我似乎无法解决问题!我几乎可以肯定这个问题是导致 Carrierwave 和雾 gem 使用亚马逊 s3。但我不确定问题出在哪个文件夹中!
这是我的初始化程序/carrierwave.rb:
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV["S3_ACCESS_KEY"], # required
:aws_secret_access_key => ENV["S3_SECRET_KEY"] # required
}
config.fog_directory = ENV["S3_BUCKET"] # required
end
=> Booting WEBrick
=> Rails 4.2.5 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/usr/local/rvm/gems/ruby-2.3.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:244:in `validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
from /usr/local/rvm/gems/ruby-2.3.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:268:in `handle_settings'
from /usr/local/rvm/gems/ruby-2.3.0/gems/fog-core-1.43.0/lib/fog/core/service.rb:98:in `new'
from /usr/local/rvm/gems/ruby-2.3.0/gems/fog-core-1.43.0/lib/fog/core/services_mixin.rb:16:in `new'
from /usr/local/rvm/gems/ruby-2.3.0/gems/fog-core-1.43.0/lib/fog/storage.rb:27:in `new'
from /usr/local/rvm/gems/ruby-2.3.0/gems/carrierwave-1.0.0/lib/carrierwave/uploader/configuration.rb:123:in `eager_load_fog'
from /usr/local/rvm/gems/ruby-2.3.0/gems/carrierwave-1.0.0/lib/carrierwave/uploader/configuration.rb:136:in `fog_credentials='
from /home/ubuntu/workspace/config/initializers/carrierwave.rb:2:in `block in <top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/carrierwave-1.0.0/lib/carrierwave/uploader/configuration.rb:158:in `configure'
from /usr/local/rvm/gems/ruby-2.3.0/gems/carrierwave-1.0.0/lib/carrierwave.rb:14:in `configure'
from /home/ubuntu/workspace/config/initializers/carrierwave.rb:1:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `block in load'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:652:in `block in load_config_initializer'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:651:in `load_config_initializer'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:616:in `block (2 levels) in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:615:in `each'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/engine.rb:615:in `block in <class:Engine>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `instance_exec'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:55:in `block in run_initializers'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:44:in `each'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:44:in `tsort_each_child'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:415:in `call'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:415:in `each_strongly_connected_component_from'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `call'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from /usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/initializable.rb:54:in `run_initializers'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/application.rb:352:in `initialize!'
from /home/ubuntu/workspace/config/environment.rb:5:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/rvm/gems/ruby-2.3.0/gems/activesupport-4.2.5/lib/active_support/dependencies.rb:274:in `require'
from /home/ubuntu/workspace/config.ru:3:in `block in <main>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/builder.rb:55:in `instance_eval'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/builder.rb:55:in `initialize'
from /home/ubuntu/workspace/config.ru:in `new'
from /home/ubuntu/workspace/config.ru:in `<main>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/builder.rb:49:in `eval'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/builder.rb:49:in `new_from_string'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/builder.rb:40:in `parse_file'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/server.rb:299:in `build_app_and_options_from_config'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/server.rb:208:in `app'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:61:in `app'
from /usr/local/rvm/gems/ruby-2.3.0/gems/rack-1.6.5/lib/rack/server.rb:336:in `wrapped_app'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:139:in `log_to_stdout'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/server.rb:78:in `start'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:80:in `block in server'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `tap'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:75:in `server'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/rvm/gems/ruby-2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
from /home/ubuntu/workspace/bin/rails:9:in `require'
from /home/ubuntu/workspace/bin/rails:9:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `load'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/rails.rb:28:in `call'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client/command.rb:7:in `call'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/client.rb:30:in `run'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/bin/spring:49:in `<top (required)>'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `load'
from /usr/local/rvm/gems/ruby-2.3.0/gems/spring-2.0.0/lib/spring/binstub.rb:31:in `<top (required)>'
from /home/ubuntu/workspace/bin/spring:13:in `require'
from /home/ubuntu/workspace/bin/spring:13:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
最佳答案
我的问题
我有一个完全相同的错误:validate_options': Missing required arguments: aws_access_key_id, aws_secret_access_key (ArgumentError)
.
存储桶限制和限制 - Amazon Simple Storage Service
https://docs.aws.amazon.com/AmazonS3/latest/dev/BucketRestrictions.html
建议
现在,我个人避免使用 secrets.yml 方法。我建议使用雾进行生产和文件存储进行开发。例如:
photo_uploader.rb
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
process resize_to_fill: [100, 100]
# Choose what kind of storage to use for this uploader:
if Rails.env.production?
storage :fog
else
storage :file
end
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Add a white list of extensions which are allowed to be uploaded.
def extension_whitelist
%w[jpg jpeg gif png]
end
end
文件
group :production do
gem 'fog', '1.42'
end
载波
if Rails.env.production?
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV["S3_ACCESS_KEY"],
aws_secret_access_key: ENV["S3_SECRET_KEY"],
}
config.fog_directory = ENV["S3_BUCKET"]
end
end
export S3_ACCESS_KEY=[...]
export S3_SECRET_KEY=[...]
export S3_BUCKET=[...]
设置它们后,您可以打印它们以检查它们是否已设置:
printenv
您还可以取消设置变量:
unset S3_ACCESS_KEY
unset S3_SECRET_KEY
unset S3_BUCKET
永恒的:
Edit the ~/.bashrc or ~/.bash_profile to set the environmental variables permanently.
希望这会有所帮助,祝您有美好的一天!
关于ruby-on-rails - 服务器中缺少必需的参数 : aws_access_key_id, aws_secret_access_key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41663925/
内部 TransactionScope 将哪个事务作为环境事务? using ( var t1 = new TransactionScope( TransactionScopeOption.Requi
我需要匹配以下模式:N.N.N 324324.234324.234324 匹配,以及 1.1.1 I have the following pattern: (\d*\.\d*\.\d*) 问题是,它
这个问题在这里已经有了答案: HTML5 required attribute not working (2 个答案) 关闭上个月。 我最近为我创建了一个网页来学习更多关于 HTML 的知识,我发现
我在 NgForm 中有以下字段: 0'" /> Dependency is required 问题是这个字段总是需要的,不管 [required]相关条件depSelected>0 . d
我有一个模型类,其中包含几个必填字段: public class UserMetadata { [Required(ErrorMessage = "Please enter a name.")]
我有一张预订表格,需要验证。某些字段的启用/禁用取决于之前选择的选项。我的问题是,我无法提交禁用字段的表单,因为它等待来自空字段的“有效”输入数据。 是否有一种方法可以仅在启用字段集时启用/禁用这些字
如何为textarea设置两个属性(默认文本,点击后隐藏,必填)? Default text HTML“认为”默认文本是我的输入。我该如何修复它?谢谢大家。 最佳答案 如果您不介意兼容性,简单
我是编码新手,所以这可能是一个非常简单的问题。 编译时出现错误: GradeAnalyzer.java:49: error: method getAverage in class GradeAnaly
我有一个带有 2 个输入字段的 from:手机和电话。我希望至少需要其中一个字段,以便可以提交表单。要么您输入手机号码,不再需要电话输入,要么反之亦然。 我发现 Jquery 验证器有条件语句,
看看下面的代码,我正在使用 required(System.ComponentModel.DataAnnotations) 命名空间,但它一直向我显示红色波浪线,并显示无法找到“type or nam
所以我有一个 knockout 原型(prototype),您可以在其中动态添加输入,然后设置每个设置。将其视为表单生成器就是这样。然而,我注意到禁用和必需的效果不太好。它将值设置为禁用或必需,但是当
我正在使用 Entity Framework 的表拆分功能来拆分我的实体数据模型,如下所示: +--------+ +--------------+ | News | | NewsI
我有 3 个关于 TransactionScopeOption 的问题。Required 把我逼疯了,我无法在网上找到他们的答案。 A. 我很难思考什么时候我必须在现实中编写这段代码?为什么我不应该将
public static int biggestArrayGap(int []a, int n) { int biggestGap = Math.abs(a[1]-a[0]); for (i
我真的发现 django 表单集令人困惑。 我尤其对以下我不太了解的概念有疑问: The formset is smart enough to ignore extra forms that were
在我的 Angular v6 应用程序中,我尝试显示一个下拉列表,并根据 bool 值将其设置为必需,该 bool 值设置在复选框的值上。以下是我的模板中的代码片段(includeModelVersi
我正在使用jquery validation插入。当我使用 required( dependency-expression ) 时,我注意到 required( dependency-expressi
代码: ArrayList marks = new ArrayList(); String output = "Class average:" + calculateAverage() + "\
static void sort (Textbook [ ] info, int numEntries) { long tempIsbn = 0; String tempTitle =
在我的 Angular v6 应用程序中,我尝试显示一个下拉列表,并根据 bool 值将其设置为必需,该 bool 值设置在复选框的值上。以下是我的模板中的代码片段(includeModelVersi
我是一名优秀的程序员,十分优秀!