我目前在我的Rails应用程序中使用asset_sync,并且我在我的Heroku应用程序中设置了环境变量.当我运行heroku配置时,我得到:
AWS_ACCESS_KEY_ID: XXXXXXXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY: XXXXXXXXXXXXXXXXXX
FOG_DIRECTORY: MY-BUCKET-NAME
FOG_PROVIDER: AWS
etc...
Run Code Online (Sandbox Code Playgroud)
当我将我的应用程序推送到Heroku时,它会尝试运行rake资产:precompile并收到以下消息:
Preparing app for Rails asset pipeline
Running: rake assets:precompile
/usr/local/bin/ruby /tmp/build_2pa7aisux9av8/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
AssetSync: using /tmp/build_2pa7aisux9av8/config/initializers/asset_sync.rb
rake aborted!
Fog directory can't be blank, Aws access key can't be blank, Aws secret access key can't be blank
Run Code Online (Sandbox Code Playgroud)
但后来我跑了:
heroku run rake assets:precompile --app my-app-name
Run Code Online (Sandbox Code Playgroud)
...它处理所有内容并同步到S3就好了:
Running `rake assets:precompile` attached to terminal... up, run.1
/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:all RAILS_ENV=staging RAILS_GROUPS=assets
AssetSync: using /app/config/initializers/asset_sync.rb
/usr/local/bin/ruby /app/vendor/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=staging RAILS_GROUPS=assets
AssetSync: using /app/config/initializers/asset_sync.rb …Run Code Online (Sandbox Code Playgroud)