我使用 gem asset_sync 和 aws 来预编译我的资产。rake assets:precompile 工作正常。在我将我的应用程序推送到 heroku 之后,然后
heroku run rake db:migrate
我收到以下错误
“未初始化的常量 AssetSync”
初始化程序/asset_sync.rb
AssetSync.configure do |config|
config.fog_provider = 'AWS'
config.aws_access_key_id = "..."
config.aws_secret_access_key = "..."
config.fog_directory = Rails.env + "-..."
config.fog_region = 'eu-west-1'
end
配置/生产.rb
config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
config.assets.enabled = true
第一次运行 run rake assets:precompile 后,我所有的 app/assets/images 都移到了 public/assets 。我已将它们从 github 中删除,并将 public/assets/* 添加到 .gitignore。这可能是问题吗?
编辑:运行 git push heroku master 时,看起来它们是预编译的
Preparing app for Rails asset pipeline
Running: rake assets:precompile
AssetSync: using /tmp/build_2ltvklj0gaxjp/config/initializers/asset_sync.rb
AssetSync: using /tmp/build_2ltvklj0gaxjp/config/initializers/asset_sync.rb
AssetSync: Syncing.
Using: Directory Search of /tmp/build_2ltvklj0gaxjp/public/assets
Uploading: assets/application-7e17d9f0ed9cb7ea50b750e2bfc7e28c.css.gz
Uploading: assets/application-7e17d9f0ed9cb7ea50b750e2bfc7e28c.css
AssetSync: Done.
Asset precompilation completed (58.04s)