Running rails 3 in production mode - ruby-on-rails-3

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

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

heroku rails logging not showing output?

I am trying to debug an issue with one of my rails controllers. It works fine locally in development but pushing to heroku there is inconsistent behavior.
I have set config.log_level = :debug in /app/config/production.rb
I have tried addin puts and logger.debug statments to the controller.
I do see the output locally but am not seeing it on heroku. Per the heroku docs at https://devcenter.heroku.com/articles/logging This shouldn't be that hard.
What am I missing?
I had to set these config values to false to reload the code app/config/environments/production.rb
config.cache_classes = false
config.action_controller.perform_caching = false

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

Permission denied for a css when deploying to heroku

I have a sample app that is using compass gem including blueprint. I just deployed this app on heroku for the first time and I'm seeing the following error in heroku logs
Errno::EACCES (Permission denied - /app/public/stylesheets/ie.css):
Is there something special required in my rails app that will make this error go away? I'm assuming it's coming because I'm using the compass gem...
Do a compass compile before deploying to heroku.
Also, in your production.rb, add the following line:
Sass::Plugin.options[:never_update] = true
This will prevent compass from compiling css at runtime (since heroku does not allow writes on filesystem)
Just set this option to true in config/environments/production.rb and everything will work fine:
config.assets.compile = true
Save ie.css from your local machine, add it into your public/stylesheets folder, and push it up to heroku.