Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails not serving assets in production or staging environments

In the process of debugging this problem, I have tried to run my application in production mode locally and it doesn't serve up any assets. Additionally, I have a staging environment in a Heroku application (separate from my production Heroku application) which is also now displaying the HTML without any assets.

To debug, I:

  1. Kill the server
  2. Clear out tmp/cache/assets
  3. Delete public/assets
  4. Run rake assets:precompile
  5. Start up the server rails s -e production
  6. Visit the page and open up web inspector and when clicking the expand arrow for the application.css link it says Reload the page to get source for: http://localhost:3000/assets/application-e1f3e0c864a153c7iu66f8772a886376.css
  7. Reloading the page does nothing.

Production.rb:

config.cache_classes = true
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.assets.compress = false
config.assets.compile = false
config.assets.digest = true

Staging.rb:

config.cache_classes = true
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.assets.compress = false
config.assets.compile = false
config.assets.digest = true

Application.rb:

config.assets.enabled = true
config.assets.version = '1.0'
config.assets.initialize_on_precompile = false

Below is how I link the stylesheet and javascript in layout/application.html.erb:

<%= stylesheet_link_tag "application", :media => "screen, handheld" %>
<%= javascript_include_tag "application" %>
like image 998
railsuser400 Avatar asked Dec 08 '22 17:12

railsuser400


1 Answers

So the problem was that the memory store was set to config.cache_store = :dalli_store which was causing errors and setting it to config.cache_store = :memory_store resolved it.

like image 123
railsuser400 Avatar answered Apr 22 '23 04:04

railsuser400