Friday, January 20, 2012

Rails 3.2 on Heroku asset:precompile issue

I just upgraded to Rails 3.2 and found that the asset precompile step of the release was not working properly.

Here is the output I was getting:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       could not connect to server: Connection refused
       Is the server running on host "" and accepting
       TCP/IP connections on port 5432?
       Tasks: TOP => environment
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation

The issue was rails was trying to connect to the database during the precompile process, and heroku is setup not to allow that. I am guessing that this issue is due to a change in the rails initialization setup in rails 3.2.

It turns out that the fix for this is very simple as long as you don't actually need to connect to the database during asset precompiling. All you need to do is add the following line to 'config/application.rb'

config.assets.initialize_on_precompile = false

Additional Resources


Philippe said...

Awesome, thank you!

Mark Essel said...

Thanks Nathan, just updating an old mostly unloved app, and ran into this problem.

If you're curious it's and it was created along with friend Tyler Gillies a web hacking life time ago (2009)

Don't do any rubying for my dayjob (nodejs, a bunch of c++ modules)

jshou said...

This helped, thanks!

Unknown said...

Thank you so much!

pavithra dass said...

Thanks for splitting your comprehension with us. It’s really useful to me & I hope it helps the people who in need of this vital information.
Java Training in Chennai
Java course in Chennai
Software Testing Training in Chennai
Web Designing Course in chennai
PHP Training in Chennai
Java Training in Tambaram
Java Training in OMR

The India said...

Rice Bags Manufacturers
Pouch Manufacturers
wall putty bag manufacturers
fertilizer bag manufacturers
seed bag manufacturers
gusseted bag manufacturers
bopp laminated bags manufacturer
Lyrics with music

The India said...

we have provide the best ppc service.
ppc company in gurgaon
website designing company in Gurgaon
PPC company in Noida
seo company in gurgaon
PPC company in Mumbai
PPC company in Chandigarh
Digital Marketing Company

The India said...

we have provide the best fridge repair service.
fridge repair in faridabad
Videocon Fridge Repair in Faridabad
Whirlpool Fridge Repair in Faridabad
Hitachi Fridge Repair In Faridabad
Washing Machine Repair in Noida
godrej washing machine repair in noida
whirlpool Washing Machine Repair in Noida
IFB washing Machine Repair in Noida
LG Washing Machine Repair in Noida

The India said...

iso certification in noida
iso certification in delhi
ce certification in delhi
iso 14001 certification in delhi
iso 22000 certification in delhi
iso consultants in noida

The India said...

iso registration in delhi
iso 22000 certification cost
ISO 9001 Certification in Noida
website designing services
SEO Service Consultant

Pradeep Appslure said...

Mobile app development company in mumbai

Tekniko Global said...

mobile app development company in delhi

creative web solution said...

Located in Delhi, Webmarts is a professionally managed digital marketing agency offering a host of demanding services. We offer SEO services, web development, web designing, social media marketing, and more services to clients in different businesses.

Pay per click packages delhi
Best PPC company in Delhi
pay per click packages in Delhi
Best ppc company Delhi
Best ppc services in Delhi
Top rated ppc agency in Delhi

Tekniko Global said...

mobile app development company in Delhi

Max Rusel said...

I feel happy about & learning more about this blog. Keep sharing your information regularly for my future reference. This content creates a new hope and inspiration within me. Thanks for sharing blog like this. The information which you have provided is better than other blog.
Visit Website: Mobile App Development Company USA. You can email us at: or Call Us: +1- 570-234-9288.

Susan said...

Eminem, also known as Marshall Mathers, is one of the most commercially successful rappers of all time, with more than 100 million albums sold worldwide. He is one of the richest rappers in the world, with an estimated net worth of $210 million. Read more in Eminem net worth.

Huongkv said...

Aivivu - đại lý chuyên vé máy bay trong nước và quốc tế

vé máy bay đi Mỹ giá bao nhiêu

chuyến bay từ mỹ về việt nam tháng 1/2021

chuyến bay thương mại từ canada về việt nam

đặt vé máy bay từ nhật về việt nam

mua vé máy bay từ hàn quốc về việt nam

Vé máy bay từ Đài Loan về VN

Ana Watson said...

Thank you for sharing this. I am new learner in coding, so it helped a lot. Thanks again.
Regards from Nulls Clash.

Aftab Shaikh said...

I didn't know about this, thanks for sharing! Gbwhatsapp