Friday, January 20, 2012

Rails 3.2 on Heroku asset:precompile issue

I just upgraded www.checkthesock.com 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 "127.0.0.1" 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

14 comments:

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

    If you're curious it's http://imagebrowser.herokuapp.com 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)

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

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

    ReplyDelete
  4. Your post is helping me a lot. Its really nice and epic. Thanks a lot for the useful info on this topic. You did it so much well. I love to see more about GB WhatsApp. Keep sharing and updating. Also share more posts with us. Thank you

    ReplyDelete
  5. Have you ever tried \ GBWhatsapp Apk, which is the Mod version of its original server which is not available on play store but you can play it by clicking here.

    ReplyDelete
  6. Flip2play.com is the online gaming website. That they provide the many service of gaming, cricket, football game etc. Play Now.

    ReplyDelete
  7. Hi, I am John Smith I am Web Developer, It is an amazing blog thanks for the sharing the blog. Frantic infotech provide the Phonegap app development such as an information about software development for costumer service. Frantic infotech also provide the ionic app development. The development of advanced web applications is Orient Software’s specialty and we will successfully fulfill all your web application development requirements, from small-sized to wider-ranged projects.

    ReplyDelete
  8. Bianca! I hope you visit us again and leave another comment. 토토사이트

    ReplyDelete
  9. Get ready to accept payment online like never before! Explore the best of payment security, encryption, and data-driven customer insights to drive incremental growth by leveraging an out-of-the-box, simplified payments ecosystem.

    ReplyDelete
  10. Our comprehensive white-label solution equips you with customizable tools and support to establish your own branded payment gateway business. From seamless integration to robust security features, ITIO paves the way for your success in the digital payments industry. Start your own payment gateway business with us.

    ReplyDelete
  11. The blog post on creating a job board website by Attract Group is a valuable resource for anyone looking to enter the job search market. Their in-depth guide covers all the necessary steps and features needed to build a successful job board platform. With their expertise and knowledge, Attract Group is setting the standard for job board website development.

    ReplyDelete