Rails custom.css not working when deployed to Heroku
Sounds like you are having problems with the asset pipeline. Check out:
https://devcenter.heroku.com/articles/rails-asset-pipeline
Are you letting Heroku precompile your assets? Personally, I precompile all my assets before deploying to Heroku.
RAILS_ENV=production bundle exec rake assets:precompile
This will precompile all your assets and puts it under a public/assets
folder. Then you can just add them to git and push to heroku.
If you do this you will be compiling manually, and you should run the precompile line before you re-deploy or update your Heroku app to catch any changes you've made in the asset pipeline.
Rails 5 - User specified CSS not working on Heroku with custom domain
Turns out Cloudflare caches all static content with certain extensions, including CSS and Javascript, by default. To get around this I added a Page Rule in my Cloudflare account to bypass the caching of www.mycustomdomain.com/application/custom_colors.css
. More info here.
Stylesheets not working after Rails app pushed to Heroku
In your stylesheet link tag, try changing 'style' to 'application'
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
By loading in the application stylesheet you are loading in all custom stylesheets as well, as long as you have:
*= require_tree .
*= require_self
included in the application.scss file.
http://guides.rubyonrails.org/asset_pipeline.html#in-production
Application.css not updating in production with heroku
You need to run bundle exec rake assets:precompile RAILS_ENV=production
or it will use your development environment config settings for precompiliation. Also, to force that the fingerprint digest changes I want you to add a comment at the very top of your application.css file so it looks like this:
/assets/stylesheets/application.css
/* Adding a comment to force a new digest and expire cached assets in browsers */
Also, make sure to include the heroku gem for serving assets in your gemfile:
gem 'rails_12factor', group: :production
Also, as a sidenote, you're asking for major performance decreases when setting config.assets.compile = true
You should make sure to find any missing assets and fix the assets paths before deploying to production and keeping the assets.compile=false
heroku not loading images from vendor .css file
I got it working bij renaming my css file to .css.scss and using the image_url( helper. Next within the helper I needed to put the subdirectory so image_url("landingpage/bgTop.jpg")
I also needed to add all images subdirectories to the asset pipeline.
application.rb
# add all asset pipeline images sub folders
Dir.glob("#{Rails.root}/app/assets/images/**/").each do |path|
config.assets.paths << path
end
And enabling some stuff in production.rb
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# Generate digests for assets URLs.
config.assets.digest = true
Heroku staging environment not deploying all images and CSS
Precompilation
All of my images are in assets/images
You must remember that Heroku relies on precompiled
assets - so it will look in the public/assets/images
, or public/images
folder
When you're using bash
to see whether the files exist, it would be far more robust to look in the /public/images
folder, as this is where the precompiled assets would normally sit anyway
Fix
There are other subtleties such as different fonts and colours of
progress bars that aren't being deployed properly
This could be a number of issues which are causing this:
- Your assets may not be present
- Your references to the assets may be incorrect
What I would do (and have done before) is firstly to precompile your assets locally, as david
recommended. You can do that relatively simply:
$ rake asssets:precompile RAILS_ENV=production
This will populate your app's public
folder with the relevant assets, which will be referenced by your various path helpers
-
Secondly, I would make sure those assets are being referenced properly. The way to do this is to use the various path helpers
which are embedded inside Rails - a prime example being asset_path
/ asset_url
:
#app/assets/stylesheets/application.css.scss
.test {
background: asset_url("test.png");
}
This references the files regardless of whether they are precompiled or not; meaning that it will give you the ability to reference them in production. I would make sure your asset files have all the correct references in order to get things working again
Related Topics
Create a Complex CSS Shape (Speaking Bubble)
Calculate Sum Opacity from Layers
How to Put a Vertical Line Down The Center of a Div
Compass-Style (Ruby) Encoding Error
HTML5 Input Number Min Max Not Working with Required
Position Fixed Not Working in Safari Version 8.0.2
How to Keep Text Opacity 100 When Its Parent Container Is Having Opacity of 50
Div Scrollbar - Any Way to Style It
How to Easily Change a Font-Sizing from Px to Em for a Big, Existing Site
CSS How to Properly Use Ems Instead of Pixels
Using 'Box-Sizing: Border-Box' with 'Inline-Block' Elements
Div Not Expanding Even with Content Inside
CSS for Double Height Text and Double Width Text in Font Style
CSS: How to Make Left Float Div to Adjust Height Dynamically
Fixed Positioned Div Is Extending Outside of HTML & Body