ruby-on-rails-3.1 – 耙资产:推送到Heroku时预编译失败

前端之家收集整理的这篇文章主要介绍了ruby-on-rails-3.1 – 耙资产:推送到Heroku时预编译失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我目前在我的Rails应用程序中使用asset_sync,并且我的Heroku应用程序中设置了环境变量.当我运行heroku配置我得到:
AWS_ACCESS_KEY_ID:     XXXXXXXXXXXXXXXXXX
AWS_SECRET_ACCESS_KEY: XXXXXXXXXXXXXXXXXX
FOG_DIRECTORY:         MY-BUCKET-NAME
FOG_PROVIDER:          AWS
etc...

当我将我的应用程序推送到Heroku时,它会尝试运行rake资源:预编译,并且我收到以下消息:

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

但是后来我跑:

heroku run rake assets:precompile --app my-app-name

…它处理所有东西,同步到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
AssetSync: Syncing.
Using: Directory Search of /app/public/assets
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css.gz
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css.gz
Uploading: assets/application-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.css
AssetSync: Done.

任何想法为什么它不会在推动时工作,但它会工作正常,当我heroku运行rake资产:预编译?

解决方法

我可以看到你正在运行资产:使用–app my-app-name选项预编译耙任务.只要确定,Heroku有多个应用程序? (例如分期和生产).如果你确实确保运行heroku配置–app我的app-name结果输出你有与heroku配置.

如果您使用上述命令获得预期结果,那么可能ENV vars在git push上不可用,如这里所建议的asset_sync_test github readme.你可以通过在你的config / environments / * .rb文件中使用以下内容

config.asset_sync.aws_access_key = ENV['AWS_ACCESS_KEY_ID']
config.asset_sync.aws_access_secret = ENV['AWS_SECRET_ACCESS_KEY']
config.asset_sync.aws_bucket = ENV['FOG_DIRECTORY']
config.asset_sync.fog_provider = ENV['FOG_PROVIDER']
原文链接:https://www.f2er.com/ruby/266469.html

猜你在找的Ruby相关文章