我正在努力让我的图片上传工作与S3,但当我创建 配置/初始化/ carrierwave.rb
并添加
CarrierWave.configure do |config|
config.fog_credentials = {
# Configuration for Amazon S3 should be made available through an Environment variable.
# For local installations, export the env variable through the shell OR
# if using Passenger, set an Apache environment variable.
#
# In Heroku, follow http://devcenter.heroku.com/articles/config-vars
#
# $ heroku config:add S3_KEY=your_s3_access_key S3_SECRET=your_s3_secret S3_REGION=eu-west-1 S3_ASSET_URL=http://assets.example.com/ S3_BUCKET_NAME=s3_bucket/folder
# Configuration for Amazon S3
:provider => 'AWS',
:aws_access_key_id => ENV['S3_KEY'],
:aws_secret_access_key => ENV['S3_SECRET'],
#region => ENV['S3_REGION']
}
# For testing, upload files to local `tmp` folder.
#if Rails.env.test? || Rails.env.cucumber?
# config.storage = :file
# config.enable_processing = false
# config.root = "#{Rails.root}/tmp"
#else
# config.storage = :fog
#end
# To let CarrierWave work on heroku
config.cache_dir = "#{Rails.root}/tmp/uploads"
config.fog_directory = ENV['S3_BUCKET_NAME']
# Generate http:// urls. Defaults to :authenticated_read (https://)
#config.s3_access_policy = :public_read
#config.fog_host = "#{ENV['S3_ASSET_URL']}/#{ENV['S3_BUCKET_NAME']}"
end
rails s甚至没有启动
我得到了一堆错误......
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
这 /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in
each' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in
阻止' 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:ininstance_exec' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30:in
运行” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:55:inblock in run_initializers' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:226:in
阻止 tsort_each” 来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:348:inblock (2 levels) in each_strongly_connected_component' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:418:in
块(2 each_strongly_connected_component_from'中的等级) 来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:427:ineach_strongly_connected_component_from' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:417:in
阻止 each_strongly_connected_component_from” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:ineach' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:44:in
tsort_each_child” 来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:411:incall' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:411:in
each_strongly_connected_component_from' 来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:347:inblock in each_strongly_connected_component' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:345:in
每个' 来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:345:incall' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:345:in
each_strongly_connected_component' 来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:224:intsort_each' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:205:in
tsort_each” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:inrun_initializers' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:352:in
初始化!” 来自/Users/atoder/Sites/rails_projects/post_app/config/environment.rb:5:in<top (required)>' from /Users/atoder/Sites/rails_projects/post_app/config.ru:3:in
需要” 来自/Users/atoder/Sites/rails_projects/post_app/config.ru:3:inblock in <main>' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in
instance_eval' 来自/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:ininitialize' from /Users/atoder/Sites/rails_projects/post_app/config.ru:in
新的” 来自/Users/atoder/Sites/rails_projects/post_app/config.ru:in<main>' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:in
eval' 来自/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:innew_from_string' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:40:in
parse_file” 来自/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:299:inbuild_app_and_options_from_config' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:208:in
应用” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:61:inapp' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:336:in
wrapped_app” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:139:inlog_to_stdout' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:78:in
开始” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:80:inblock in server' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:in
点击” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:75:inserver' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in
run_command!” 来自/usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands.rb:17:in<top (required)>' from /Users/atoder/Sites/rails_projects/post_app/bin/rails:8:in
需要” 来自/ Users / atoder / Sites / rails_projects / post_app / bin / rails:8:in<top (required)>' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client/rails.rb:27:in
load' 来自/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client/rails.rb:27:incall' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client/command.rb:7:in
称之为” 来自/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client.rb:26:inrun' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/bin/spring:48:in
” 来自/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/binstub.rb:11:inload' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/binstub.rb:11:in
” 来自/usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:inrequire' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in
需要” 来自/ Users / atoder / Sites / rails_projects / post_app / bin / spring:16:in''
答案 0 :(得分:1)
好的我发现了问题...来自application.yml的设置没有加载..我通过将它添加到application.rb来修复它。
if File.exists?(File.expand_path('../application.yml', __FILE__))
ENV.update YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
end