2015-02-07 76 views
0

我试图让我的图片上传工作,S3,但是当我创建 配置/初始化/ carrierwave.rb服务器导轨时候我加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                                                    

轨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在' 从/ usr/ each' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/engine.rb:615:in 块local/lib/ruby​​/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:30: instance_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: block in run_initializers' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:226:in block in tsort_each' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0 /tsort.rb:348:in block (2 levels) in each_strongly_connected_component' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:418:in block(2 级别)位于/usr/local/Cellar/ruby/2.1.5/l的each_strongly_connected_component_from' ib/ruby​​/2.1.0/tsort.rb:427:在 each_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' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails从/ usr /initializable.rb:44:in each' 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:in call' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:411:in each_strongly_connected_component_from' /local/Cellar/ruby​​/2.1.5/lib/ruby​​/2.1.0/tsort.rb:347:来自/usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0的block in each_strongly_connected_component' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:345:in每个' /tsort.rb:345:in call' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:345:in each_strongly_connected_component' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:224:in tsort_each' from /usr/local/Cellar/ruby/2.1.5/lib/ruby/2.1.0/tsort.rb:205:in tsort_e ach' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/initializable.rb:54:in run_initializers' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/application.rb:352:in initialize!' 从/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:in block in <main>' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in instance_eval的' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:55:in initialize' from /Users/atoder/Sites/rails_projects/post_app/config.ru:in新的' from/Users/atoder/Sites/rails_projects /来自/usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:49:in new_from_string' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/builder.rb:40:in parse_file' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:299:in build_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 app' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:61:in app' from /usr/local/lib/ruby/gems/2.1.0/gems/rack-1.6.0/lib/rack/server.rb:336:in wrapped_app' from/usr/local/lib /ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/server.rb:139:in log_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:in block 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:in server' from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.2.0/lib/rails/commands/commands_tasks.rb:39:in run_command!' from /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要求' from/Users/atoder/Sites/rails_projects/post_app/bin/rails:8:<top (required)>' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client/rails.rb:27:in 从/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client/rails.rb:27加载' :在 '从/usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client.rb:26:in run' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/bin/spring:48:in ' 从/ usr/ call' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/client/command.rb:7:in 呼叫local/lib/ruby​​/gems/2.1.0/gems/spring-1.2.0/lib/spring/binstub.rb:11: load' from /usr/local/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/binstub.rb:11:in ' from /usr/local/lib/ruby/site_ruby/2.1.0 /rubygems/core_ext/kernel_require.rb:54:in require' from /usr/local/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in 要求 '从/用户/ atoder /网站/ rails_projects/post_app /斌/春 :16:`'

+0

是否设置了'S3_KEY','S3_SECRET'和'S3_BUCKET_NAME'? – 2015-02-07 22:35:13

+0

@KenStipek yep ..我让他们为heroku设置,也在我的application.yml文件中 – CodeCrack 2015-02-07 22:37:23

+0

因此,如果你打开rails控制台并运行'puts env ['S3_KEY']'它会吐出密钥? – 2015-02-07 22:39:08

回答

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 
相关问题