Update September 3rd this is not working either.....
更新9月3日这也不起作用.....
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS' # required
:aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"] # required
:aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"] # required
}
config.fog_directory = ENV["AWS_S3_BUCKET"] # required
end
I am using the figaro gem to store env variables of my aws credentials.
我正在使用figaro gem来存储我的aws凭据的env变量。
here is my initializers/carrierwave.rb file
这是我的initializers / carrierwave.rb文件
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS' # required
:aws_access_key_id => ENV[AWS_ACCESS_KEY_ID] # required
:aws_secret_access_key => ENV[AWS_SECRET_ACCESS_KEY] # required
#:region => 'us-east-1', # optional, defaults to 'us-east-1'
#:host => 's3.example.com', # optional, defaults to nil
#:endpoint => 'https://s3.example.com:8080' # optional, defaults to nil
}
config.fog_directory = ENV[AWS_S3_BUCKET] # required
end
when I do rails s I am getting this error
当我做rails时,我收到了这个错误
/initializers/carrierwave.rb:6: syntax error, unexpected tSYMBEG, expecting '}' (SyntaxError)
:aws_access_key_id => ENV...
^
/Users/judyngai/tryagain_newproject/onemonth/lintong/config/initializers/carrierwave.rb:7: syntax error, unexpected =>, expecting keyword_end
:aws_secret_access_key => ENV[AWS_SECRET_ACCESS_KEY] ...
here is my application.yml as generated by the figaro gem
这是我的application.yml,由figaro gem生成
AWS_ACCESS_KEY_ID: "blahblahblahblah"
AWS_SECRET_ACCESS_KEY: "blahblahblahblah"
AWS_S3_BUCKET: "blahblahblahblah"
what am I doing wrong?
我究竟做错了什么?
1 个解决方案
#1
3
You need to put quotes around your key names, and need commas to separate each item (just like any Ruby hash):
你需要在键名周围加上引号,并且需要使用逗号分隔每个项目(就像任何Ruby哈希一样):
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
:aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
}
config.fog_directory = ENV["AWS_S3_BUCKET"] # required
end
#1
3
You need to put quotes around your key names, and need commas to separate each item (just like any Ruby hash):
你需要在键名周围加上引号,并且需要使用逗号分隔每个项目(就像任何Ruby哈希一样):
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV["AWS_ACCESS_KEY_ID"],
:aws_secret_access_key => ENV["AWS_SECRET_ACCESS_KEY"]
}
config.fog_directory = ENV["AWS_S3_BUCKET"] # required
end