Note that there are some explanatory texts on larger screens.

plurals
  1. POBackground image issue in Rails 3.1 asset pipe line with cloudfront CDN
    primarykey
    data
    text
    <p>I have a rails 3.1.0 heroku app that uses Amazon cloudfront cdn to deliver assets.Everything works fine except for the background image, its not rendered.Inspecting the request in firebug/Yslow shows <code>GET box.png 403 Forbidden d2g4atxxxxxx.cloudfront.net 231 B 54.240.xxx.xxx:xx</code> and the url to the image is <code>http://d2g4xxxxxxxx.cloudfront.net/assets/box.png</code>.As you can see it is not the image is not fingerprinted.In application.css i have this <code>background-image:url('box.png');</code> <strong>Things that i tried</strong></p> <p><strong>1st try</strong></p> <p>I appended .erb to application.css and added <code>background-image:url(&lt;%=asset_path 'box.png'%&gt;);</code> Then i added <code>config.action_controller.asset_host="http://mybucket_name.com.s3.amazonaws.com"</code><br> Then i did </p> <pre><code>bundle exec rake assets:precompile </code></pre> <p>Then i switched back to </p> <pre><code>config.action_controller.asset_host ="http://d2gxxxxxxx.cloudfront.net" </code></pre> <p>Then i did </p> <pre><code> git add application.css.erb git commit -a git push origin master </code></pre> <p>But it didn't work</p> <p><strong>2nd try</strong></p> <p>I appended .scss to application.css and added <code>background-image:image-url('box.png');</code> Then i added <code>config.action_controller.asset_host="http://mybucket_name.com.s3.amazonaws.com"</code><br> Then i did </p> <pre><code>bundle exec rake assets:precompile </code></pre> <p>Then i switched back to </p> <pre><code>config.action_controller.asset_host ="http://d2gxxxxxxx.cloudfront.net" </code></pre> <p>Then i did </p> <p>Then i added <code>gem 'compass-rails'</code> to a gemfile and created compass.rb and added this</p> <pre><code> #In compass.rb project_type = :rails line_comments = false generated_images_dir = "public/assets" bundle install git add application.css.scss compass.rb git commit -a git push origin master </code></pre> <p>But also it didn't work</p> <p><strong>What I have</strong></p> <p>gemfile</p> <pre><code> source 'http://rubygems.org' gem 'rails', '3.1.0.rc8' group :development do gem 'sqlite3' end gem 'geocoder' gem "dynamic_form" gem 'devise' gem 'rack', '1.3.3' gem 'execjs' gem 'carrierwave' gem "meta_search",'&gt;= 1.1.0.pre' gem "thumbs_up" gem 'geocoder' gem 'fog' gem 'koala' group :production do gem 'pg' gem 'therubyracer' gem 'unicorn' end gem 'jquery-rails' gem 'thin' gem 'mongrel', '1.2.0.pre2', :group =&gt; :development gem 'sass-rails', " ~&gt; 3.1.0.rc" gem 'coffee-rails', "~&gt; 3.1.0.rc" gem 'uglifier' gem 'yui-compressor' gem "asset_sync" # gem 'compass-rails' group :test do # Pretty printed test output gem 'turn', :require =&gt; false gem 'rspec-rails' gem "factory_girl_rails" gem 'capybara' gem "guard-rspec" end </code></pre> <p>app/config/enviroenments/production.rb</p> <pre><code> Deals::Application.configure do config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true config.action_controller.asset_host ="http://d2g4xxxxxx.cloudfront.net" config.serve_static_assets = true # Compress JavaScripts and CSS config.assets.compress = true config.assets.compile = true config.assets.digest = true config.assets.css_compressor = :yui config.assets.js_compressor = :uglifier config.i18n.fallbacks = true config.active_support.deprecation = :notify end </code></pre> <p><strong>Question</strong></p> <p>What am i doing wrong?or what step am i missing, can somebody walk me through the steps please?I have spend the whole week reading different blogs and different questions about this with no luck.Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload