Heroku assets not loading - ruby-on-rails-3

I have added new image in assets but after pushing on Heroku they remain there for few hours and again old images start displaying and i have also compiled Heroku assets but still new images disappear after few hours
RAILS_ENV=production bundle exec rake assets:precompile

Edit these two lines from false to true in production.rb file.
config.assets.compile = true
config.assets.digest = true
Second, if you've syntax like this for your images
background: url("imgo.jpg")
Change it to
background: image-url("image.jpg")
Found solution here

Related

Rails 3 Development Asset Pipeline Directs to Public Folder

I just pulled down two new rails 3.2.6 projects that I have designated for some clean up. While attempting to make some UI changes I realized that even in development the asset pipeline was routing towards the public/assets folder.
After making some changes to the scss, I ran rake assets:clean followed by rake assets:precompile. Both ran without error and I restarted my localhost, and the styling was broken.
I've walked through the rails asset pipeline guide, as well as some other documentation that hasn't really provided the answer I need.
I attempted adding config.serve_static_assets = falseto the development.rb file in the config folder, however this as well did not render any scss.
Can anyone explain what is happening, and the best method of resolution?
Thanks
Add below statement to development.rb to prevent loading of files from public/assets.
config.serve_static_assets = false
Now restart the server, You will get better view.
To precomple the code in Test mode. -
Add this configuration to test.rb
config.assets.compile = false
config.serve_static_assets = true

Serving assets as separate files in Heroku - Rails 3

I am working on a Rails 3 app and I need to get my js files in separate files on Heroku for debugging. On the local host when I run in development ENV it works fine.
On Heroku it serves the files separately and at the same time serves application.js with all the code in it, so the code is loaded twice which creates a lot of problems.
Things I tried:
1) Setting RACK_ENV and RAILS_ENV to 'development' in Heroku
2) Setting:
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
in both production.rb and development.rb
3) copying the entire content of development.rb to production.rb
4) using
<%= javascript_include_tag "application", debug: true %>
Nothing helps, I still get application.js with all the code and all the separate files at the same time.
You kind help will be very appreciated.
Thank you!
You can turn off rails asset pipeline by setting config.assets.enabled = false in config/application.rb

Rails 3.1.3 Production Stylesheets not compiling consistently with Development

I have a rails app which compiles my stylesheets correctly in development. In production however, it doesn't.
I've tried to make the configuration values the same for my production config by setting
config.assets.compress = false
config.assets.compile = false
config.assets.digest = true
config.assets.debug = true
This does almost everything, it doesn't display the comments about where the css was compiled from like it does on development, and I haven't figured out how to enable that. My first question is how would I enable that in production for debugging?
Next - specificially using Spree 0.70.2, and what happens is in development the stylesheets from the gem are compiled. In production, they're being ignored. What could be the cause of this?
Is there a way to follow what's being compiled, a way to trace it (--trace when you run rake doesn't give you much relevant info)
Thanks

Javascript file is not updated in development with Rails

I changed a JS file under app/assets/javascripts but it is still the same. I deleted the file and re-created but the content is still the old one. This is my development.rb file:
App::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
config.serve_static_assets = false
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.default_url_options = { :host => "lvh.me:3000" }
# Raise exception on mass assignment protection for Active Record models
# config.active_record.mass_assignment_sanitizer = :strict
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL)
config.active_record.auto_explain_threshold_in_seconds = 0.5
config.log_tags = [:uuid, :remote_ip]
end
The JS file is loaded inside the header tag with this code:
<script src="/assets/deals.js?body=1" type="text/javascript"></script>
which is the normal way JS is loaded in development
Try to clear precompiled assets:
bundle exec rake assets:clean
Try to delete the tmp folder and then restart the server - rails s.
That will do it.
bundle exec rake assets:clean and then bundle exec rake assets:precompile
Or delete the public/assets folder, and restart the app
Check for sprockets-rails gem
In my case I upgraded to Rails 7, and for some reason, the javascript files were not updated. Spent many hours trying to work out why.
I finally discovered the culprit - in my case - somehow, I had removed the sprockets-rails gem. I could have easily lost many months trying to figure this out.
I have similar issue in my app running Rails 6 and 7. When I add console.log into one of the javascript controllers there won't be any log in the browser console, and it looks like the console.log is not even there.
I have been having issue for quite some time and have not been able to pinpoint the exact reason, it might be due to bundler installed globally, conflict between rvm and asdf, config for overmind, yarn or npm. But I found the 3 commands that resolve this problem for some time and I usually run them one after another
rails assets:clobber
rake tmp:cache:clear
rake assets:precompile

Running rails 3 in production mode

I am having issues running my rails 3 project in production mode.
I am getting tons of routing errors, and they are all in the public folder, images, stylesheets and javascript. No other resources seem to have this problem.
Everything works fine in development and test.
In production.rb file change the following from false to true
config.serve_static_assets = true