Open hexcodejosh opened 10 years ago
Updated this to remove the loop and only keep the explicit naming of the assets that need precompiled. This fixes the $c_green failure I was seeing in https://github.com/spree/spree_fancy/issues/41
@hexcodejosh So what are the steps to reproduce this issue?
Basically, install spree + spree_fancy, push to heroku, and use assets_sync to save assets to amazon s3.
spree's built in s3 support handles products' assets correctly, but doesn't by itself seem to handle precompiled assets. The consensus on the web seemed to be to use asset_sync as well to upload all assets to s3 during the precompile phase.
Once you get that far, installing spree_fancy will work locally, and will appear to work on heroku as well (no errors during precompile)... but I found that many of the spree_fancy assets (icons, bx_loader.gif, etc) would return 404 on page load. The most visible problem was the shopping cart and other icons showed up as empty boxes (in chrome).
Soooooooo..... it must be the combination of trying to do all of these things at once that exposes the issue. The fix I'm proposing calls out the assets that spree_fancy provides, adds them to the precompiled asset array, so that when assets:precompile is run, they are picked up and compiled along with all the other assets.
Once they're in that pipeline, then asset_sync picks them up and uploads them to s3, and everything works after that point.
For reference, my current Gemfile is:
source 'https://rubygems.org'
ruby '2.0.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0'
# Postgres is required by heroku
gem 'pg'
# Not sure which of three following are required or optional.
gem 'sass-rails', '~> 4.0.0'
gem 'compass'
gem 'compass-rails'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# asset_sync uploads all of your precompiled assets to Amazon S3 (or others) and
# alters Rails to serve them from s3.
gem 'asset_sync'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
gem 'spree', '2.1.1'
gem 'spree_gateway', :git => 'https://github.com/spree/spree_gateway.git', :branch => '2-1-stable'
gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', :branch => '2-1-stable'
#gem 'spree_fancy', :github => 'spree/spree_fancy', :branch => '2-1-stable'
gem 'spree_fancy', :github => 'hexcodejosh/spree_fancy', :tag => 'better_fix_for_missing_assets'
gem 'spree_paypal_express', :github => "radar/better_spree_paypal_express", :branch => "2-1-stable"
# Not 100% sure this is necessary. Seemed recommended from various Googling.
gem 'rails_12factor', group: :production
I've have spree working on heroku, and have been using asset_sync to sync the precompiled assets. I noticed after installing spree_fancy that spree_fancy's assets were not being sync'd. I originally thought it was a bug in asset_sync, but instead have traced it down to what looks like a bug in spree_fancy. It doesn't appear that any of the assets are being added to config.assets.precompile array.
Hacking around, I added the following to lib/spree_fancy/engine.rb:
I'm not sure if the manual entries or the loop are doing the job (blush) but this fixes my issue -- the precompiled assets are then picked up by asset_sync. It seems pretty clear that the assets are not making it into the list.
Can anyone validate what I'm seeing? Is this this "right" place to make the fix? If so, I can create a fork, clean it up, and push back a fix.
Let me know & thanks for looking...