Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Precompiling Assets with Rails 3.1

I'm pushing changes to Heroku and I get ...

rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?

When I consult the Heroku documentation Here, it tells me I need to "configure a nonexistent database in your local config/database.yml" I'm not sure how to create a "nonexistent database"? I'm a beginner and would appreciate any help you can give me. Thanks.

like image 734
Alekx Avatar asked Nov 03 '11 03:11

Alekx


People also ask

How do you Precompile rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What is assets pipeline in rails?

1 What is the Asset Pipeline? The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass, and ERB.

What does rake assets Clean do?

rake assets:clean Only removes old assets (keeps the most recent 3 copies) from public/assets . Useful when doing rolling deploys that may still be serving old assets while the new ones are being compiled.

What are rails sprockets?

Sprockets is a crucial Ruby library that is used to serve and compile web assets. However, in Rails 7.0 the library becomes an optional dependency unless the application needs to use Sprockets. In such situations, the sprockets-rails gem will have to be added to the Gemfile .


1 Answers

On Heroku, you must set this line in your config/application.rb:

config.assets.initialize_on_precompile = false

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

For faster asset precompiles, you can partially load your application by setting config.assets.initialize_on_precompile to false in config/application.rb, though in that case templates cannot see application objects or methods. Heroku requires this to be false.

like image 160
Jamon Holmgren Avatar answered Sep 21 '22 06:09

Jamon Holmgren