Failed to load the resource: the server responded with a status of 404 (not found)

I have a rails application that works fine on the local computer. But when I deploy it to Heroku, I get the following error in the browser:

Failed to load resource: the server responded with a status of 404 (Not Found) http://hollow-cloud-nnn.herokuapp.com/stylesheets/application.css Failed to load resource: the server responded with a status of 404 (Not Found) http://hollow-cloud-nnn.herokuapp.com/javascripts/application.js 

I have these files in the app \ assets \ javascript and \ app \ assets \ stylesheets folder.

Here is my config \ production.rb:

 # Disable Rails static asset server (Apache or nginx will already do this) config.serve_static_assets = false # Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = true # Generate digests for assets URLs config.assets.digest = true 

Here is the deployment console output:

  Using mongoid (2.4.7) Using rails (3.2.1) Using sass (3.1.15) Using sass-rails (3.2.5) Using uglifier (1.2.3) Your bundle is complete! It was installed into ./vendor/bundle Cleaning up the bundler cache. -----> Writing config/database.yml to read from DATABASE_URL -----> Rails plugin injection Injecting rails_log_stdout Injecting rails3_serve_static_assets -----> Discovering process types Procfile declares types -> (none) Default types for Ruby/Rails -> console, rake, web, worker -----> Compiled slug size is 15.8MB -----> Launching... done, v24 http://hollow-cloud-7412.herokuapp.com deployed to Heroku To git@heroku.com:hollow-cloud-7412.git cb8ded3..dc103ac master -> master 

How can i fix this?

+8
ruby-on-rails heroku
source share
2 answers

You must precompile the assets or set config.assets.compile = true in your production environment.

Additional information is available in the dev hero center, read how to use the ravel 3.1+ resource pipeline for the hero .

+17
source share

It seems that you are a mongoid user running 3.1+ rails. This is a fairly common problem for Mongoid users, as the documentation states that you delete this line in config/application.rb

 require 'rails/all' 

To solve this problem, add the following line to config/application.rb

 require 'sprocket/railtie' 
0
source share

All Articles