Removed Stylesheet from application but it still appears on Heroku - css

I remove a stylesheet that contained media queries for specific devices. The changes appear on my local version. When I view it in production on heroku the media queries are still there. I asset removed it from the assets initializer # Rails.application.config.assets.precompile += %w( apps.css ). I ran heroku run assets:clean and restarted the server but it still remains. git status shows that there are not uncommitted changes.

You will have to do a couple of more steps:
$ rake assets:precompile
$ git add .
$ git commit
... deploy to heroku
rake assets:clean just removes the compiled assets locally; without running the precompile step to generate new assets, the assets on heroku does not get refreshed.

Related

Rails does not provide a new application.css on staging environment

I am deploying my ruby rails application with capistrano and have an development, staging and production environment. On my development env everything works fine.
Now I've pushed my updates to our staging env but no new application.css has been generated. I have deleted the old application.css manually on the staging env and tried my deployment again - without any luck. All I get now is an error from the web console, that application-xxxxx.cs could not be found. How can I generate a new application.css?
I have already tried it with cap staging deploy assets:precompile but without any luck.
In my staging.rb:
config.assets.compile = true
In my assets.rb:
Rails.application.config.assets.version = '1.1'
Rails.application.config.assets.precompile += %w( season.css)
Rails.application.config.assets.precompile += %w( dashboard.css)
Rails.application.config.assets.paths << Rails.root.join('node_modules')
Capfile:
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/puma'
install_plugin Capistrano::Puma
install_plugin Capistrano::Puma::Daemon
require 'whenever/capistrano'
Addition:
When I run cap staging deploy it shows that precompile is executed but as stated above no new application.css file has been generated.
00:53 deploy:assets:precompile
01 ~/.rvm/bin/rvm default do bundle exec rake assets:precompile
✔ 01 deploy#3.121.33.42 5.630s
If any other information is needed, please let me know.

RoR App: "The asset 'application.css' is not present in the asset pipeline" after moving to production server

after moving my Ruby on Rails app to production server (AWS EC2 Amazon Linux 2018.03) pages don't render, because of error "The asset 'application.css' is not present in the asset pipeline" (precompiled files are presents in public/assets):
production.log
However, when I refresh my application (sometimes more then once), this file is found in cache and page is rendering correctly. It seems like server doesn't wait for file precompilation or something like that. It happens not only on first page entry, but every change of view.
I followed tips from post:
application.css not in asset pipeline, but it didn't help.
My stack:
ruby 2.6.3
rails 5.2.3
Unicorn 5.5.1
nginx 1.14.1
I will be really grateful for any hints.
You can confirm your app/assets/stylesheets folder it should have application.css file and you will have to precompile assets in production environment before go/start server in production environment.
You can precompile assets using
RAILS_ENV=production rails assets:precompile
If it still does not work then you can try the config.assets.compile option to true in production.rb so it will do live compilation. Although it should be false in production environment as it impact on performance.
config.assets.compile = true
I had this problem on a GitHub Action workflow, and adding this line fixed it:
bundle exec rake assets:precompile
Example
run: |
bundle exec rails db:prepare
bundle exec rake assets:precompile # <--- here

Git push is not pushing css to Heroku

I am working on my first rails app. I have deployed it on heroku, git push is not pushing the css files/settings, what do i do? What could have gone wrong? (css is working locally)
EDIT: This is the output of cat .gitignore
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
# Ignore all logfiles and tempfiles.
/log/*.log
/tmp

CSS not showing as same as local on Heroku

Here's what I did already before thinking this is a duplicate.
I let heroku do the rake assets:precompile
I did it locally, added it to git and pushed
None of these worked? I am thinking maybe Heroku somehow cached the assets which doesn't make sense to me but I have no other ideas at this point. Is this cache idea really possible on Heroku?
As far as I know Heroku doesn't cache any assets.
Try to run the following:
rm -rf public/cache
git commit -am "Removing cache files"
git push heroku master
If it doesn't work try this:
rm -rf public/cache
RAILS_ENV=production bundle exec rake assets:precompile
git add public/cache
git commit -am "Updated Compiled assets"
git push heroku master
You've probably already read Rails Asset Pipeline on Heroku Cedar, if not check it out.
Hope it helps.

Rails 3.1 Asset Pipeline Fingerprinting

Simple question:
I've got a Rails 3.1 app running in staging, which is RAILS_ENV=production. My problem is this: stylesheet_link_tag produces a different fingerprint for my css files than the fingerprint that was produced by rake assets:precompile.
So when I request a page, the link to the stylesheet is looking for a file like:
/assets/front-1e3a4454e0d5434eccac1a053ca4c7fd.css
but in reality the file sitting in public/assets is
front-60b624d69d97b3ac5f288c54245a5ed5.css
and the browser returns a 404 Not Found.
Here is my linlk stylesheet_link_tag :front. Can anybody explain to me why this happens?
I've been having the same exact issue. Best I can tell, this occurs when the precompile task runs during a capistrano deploy. I've had to remove the precompile from deployment and run the
rake assets:precompile RAILS_ENV=production from the release directory after the app has been deployed. It's a pain if you're pushing code frequently.

Resources