Reputation: 5363
I am trying to get my image upload work with S3 but when I create config/initializers/carrierwave.rb
and add
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 doesn't even start
I get bunch of errors like so..
=> 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
from /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
block in ' from /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
run' from /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
block in tsort_each' from /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
block (2 levels) in each_strongly_connected_component_from' 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
block in each_strongly_connected_component_from' 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' from /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' 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
each' from /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' from /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' from /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
initialize!' from /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
require' from /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' from /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
new' from /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' from /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' from /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
app' from /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' from /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
start' from /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
tap' from /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!' 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
require' from /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' from /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
call' from /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
' from /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
' from /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
require' from /Users/atoder/Sites/rails_projects/post_app/bin/spring:16:in `'
Upvotes: 0
Views: 251
Reputation: 5363
Ok I figured out the problem... the settings from application.yml were not getting loaded.. I fixed it by adding this to application.rb
if File.exists?(File.expand_path('../application.yml', __FILE__))
ENV.update YAML.load(File.read(File.expand_path('../application.yml', __FILE__)))
end
Upvotes: 1